c# - typeof(interface).IsAssignableFrom(intptr) returns true -


i need go through properties implement interface, , have intptr property passes isassignablefrom condotion.

is there other way check if property implements interface?

this method goes through properties:

protected void setowner() {     ienumerable<propertyinfo> sourceproperties = this.gettype().getproperties();      foreach (propertyinfo pi in sourceproperties)     {         if (pi.name != "owner" && pi.declaringtype.getinterface("iownersystem") != null)         //i tried too: typeof(iownersystem).isassignablefrom(pi.declaringtype))         {             iownersystem systm = (iownersystem)pi.getvalue(this, null);             if (systm != null)             {                 systm.owner = this;             }         }     } } 

and class:

public abstract class aircraft : ownersystem {    //a bunch of properties...      public abstract intptr videowindow { get; } } 

pi.declaringtype type declares property, not type of property. in case, declaringtype aircraft or 1 of base classes. should use pi.propertytype instead.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -