c# - How can I access a "private virtual" property starting with Underscore through Reflection -



c# - How can I access a "private virtual" property starting with Underscore through Reflection -

i trying access next property using reflection because don't have original source code (suppose decompiled through reflector). seems special beingness "private virtual" or maybe because has "_" in origin of property. can access other private properties no problem except one. can't figure out doing wrong:

private virtual string _myproperty { { homecoming this.__myproperty; } [methodimpl(methodimploptions.synchronized)] set { this.__myproperty = "blah"; } }

i tried access using reflection following:

reflectionhelper.getpropertyvalue(<class of above property>, "_myproperty")

using next method in reflectionhelper class:

public shared function getpropertyvalue(byval obj object, byval prop string) object dim objecttype type = obj.gettype() dim bindingflags bindingflags = bindingflags.getproperty or bindingflags.public or bindingflags.nonpublic or bindingflags.instance dim propinfo propertyinfo = objecttype.getproperty(prop, bindingflags) if propinfo nil throw new exception("property: '" & prop & "' not found in: " & objecttype.tostring) end if homecoming propinfo.getvalue(obj, nothing) end function

private virtual string _myproperty should compiler error. both "a private method cannot polymorphic" , "a virtual method cannot private" when seek in vs 2010.

this makes sense, because private means "cannot accessed outside of class (including derived classes)", , virtual means "can overridden derived classes". if override method in derived class, phone call derived class, making no longer private.

i wonder if decompling code written in managed c++. think next possible in visual c++:

interface class { property bool isok { bool get(); } }; public ref class abstract : { private: virtual property bool isfine { bool get() sealed = i::isok::get { homecoming false; } } };

edit: found bug study mentioned bug in visual c++ compiler: https://connect.microsoft.com/visualstudio/feedback/details/651255/c-cli-property-overriding-and-renaming.

c# .net vb.net

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -