How to check if an interface inherits/extends another interface
I needed this because the factories in my current project should all inherit from IDomainFactory. This is a marker interface used for AutoFac setup, so our Dependency Injection works.
It's fairly simple to know which interfaces a given interface inherits from:
if (!type.GetInterfaces().Contains(typeof(IDomainFactory))) {
Assert.Fail("...");
}
Written by Peter Morlion
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#C#
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#