C# generic cast -


i have interface called ieditor

public interface ieditor<t>      t: specialobject 

specialobject abstract class.

here´s problem:

i have class inherits specialobject , view implements ieditor interface

public class view : ieditor<person> 

now, have check whether view implements ieditor<specialobject>

boolean iseditor = view ieditor<specialobject> 

but ieditor false

is there possibility check if view ieditor<specialobject>?

edit

i have method called when closing event raised. views passed method can implement ieditor, can implement interface. in example iview

  void closing(object sender, myeventargs e)   {       if(e.item iview)       {           // closing tasks            if(e.item ieditor<specialobject>)          // false           {               // special tasks               var editor = e.item ieditor<specialobject>;                var storededitobect = editor.storedobject;                // more tasks           }       } else if(e.item isomeotherview)       {}   } 

i have classes called person, address , on. inherits specialobject. in case e.item inherits ieditor or ieditor because of that, have cast base class access defaut property fields

create non-generic base interface. eg:

public interface ieditor {}  public interface ieditor<t> : ieditor ... {} 

then check ieditor.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -