Last Updated: February 25, 2016
·
761
· petermorlion

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("...");
}