c# - ReflectedType of MemberExpression is the base class rather than actual class used -


so have following classes

class person {     virtual string property{get;set;} } 

and

class manager : person {     [someattribute("hello")]     override string property {get;set;} } 

if have member expression on type manager, ie:

property prop = propertygetter.getprop<manager>(p => p.property) 

then reflectedtype of memberexpression person, rather manager. means attribute information lost. so:

var attribute = prop.getattribute<someattribute>(); 

then attribute null.

i'm assuming because property base class, not defined in manager, how can around this?

the issue fixed if use new keyword on property rather virtual , override.

i think has fact there no instance of type manager.

another way fix change implementation of getprop

return typeof(t).getproperty(property.name) 

rather returning property


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -