You can create a wrapper around your target type, for example, you can have a class that they provide:
public class TheirClass
{
public void DoSomething();
}
With the help of which you can define the interface:
public interface ITheirClass
{
void DoSomething();
}
And implement this interface in a wrapper class:
public class TheirClassWrapper : TheirClass, ITheirClass
{
}
Or, if the class they provided is sealed, you need to do it a little differently:
public class TheirClassWrapper : ITheirClass
{
private TheirClass instance = new TheirClass();
public void DoSomething()
{
instance.DoSomething();
}
}
You can then enter this interface instead.
I know that in MEF we can export specific types and enter them correctly, but I'm not sure about other IoC containers.
source
share