vb.net - How can I create delegates to a property of unknown type? -


i'm using reflection access object's properties name, call method. relatively slow operation on thousands of iterations, when cache propertyinfo each property. i'm trying come faster using delegates, vb.net won't allow me call createdelegate on object without knowing return type of property @ compile time. how can this?

  • i access properties via (string) name
  • the return type of property unknown @ compile time
  • i'm trying create delegate access 1 or more properties on thousands of instances of object

edit: code follows

testc example object contains properties i'm acessing name. del delegate want use call property on instance of testc.

public class testc         public property prop1 string         public property prop2 double         public property prop3 integer         public property prop4 string         public property prop5 string         public property prop6 string end class  public delegate function del() object 

the first time access each property, use reflection property it's name, , attempt build delegate access on other instances of object in future.

dim pi reflection.propertyinfo = obj.gettype().getproperty(propname) dim mydelegate object = system.delegate.createdelegate(gettype(del), pi.getgetmethod()) 

calling createdelegate throws exception:

system.argumentexception: cannot bind target method because signature or security transparency not compatible of delegate type.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -