The ExportFactory constructor accepts a function that returns a tuple containing the export, and another function that frees the export. So you can do something like this:
static Tuple<ISomething, Action> CreateMock()
{
return new Tuple<ISomething, Action>(new MockSomething(),
() => Console.WriteLine("Releasing..."));
}
and add it to the constructor of another class with something like:
var obj = new OtherClass(new ExportFactory<ISomething>(CreateMock));
source
share