I have an interface called IEditor
public interface IEditor<T>
where T: SpecialObject
SpecialObject
is an abstract class.
Here´s my problem:
I have a class which inherits from SpecialObject
and a view which implements this IEditor
interface
public class View : IEditor<Person>
Now, I have to check whether View implements IEditor<SpecialObject>
Boolean isEditor = View is IEditor<SpecialObject>
But IEditor
is always false
Is there any possibility to check if View is IEditor<SpecialObject>
?
I have a method which is called when a closing event is raised. The views which are passed to this method can implement IEditor, but they also can implement another interface. In example IView
void Closing(object sender, MyEventArgs e)
{
if(e.Item is IView)
{
// DO some closing tasks
if(e.Item is IEditor<SpecialObject>) // always false
{
// Do some special tasks
var editor = e.Item as IEditor<SpecialObject>;
var storedEditObect = editor.StoredObject;
// more tasks
}
} else if(e.Item is ISomeOtherView)
{}
}
I have some classes called Person, Address and so on. They all inherits from SpecialObject. In some case e.Item inherits from IEditor or from IEditor Because of that, I have to cast to my base class to access the defaut property fields
Create a non-generic base interface. Eg:
public interface IEditor {}
public interface IEditor<T> : IEditor ... {}
Then check for IEditor
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With