I am trying to release a generic instance or singleton value. Does anyone know how to do this? Do I need to update the catalog? I am studying MEF, so please help.
Class example
[Export]
public class Foo
{
public RandomProperty {get;set;}
[ImportConstructor]
public Foo() {}
}
You can create it something like this:
var fooSingleton = ServiceLocator.GetInstance(typeof(Foo));
Everything is fine and good, but ideally I would like to do something like this
Container.Replace(oldFoo, newFoo);
So when will I call him again
var fooSingleton = ServiceLocator.GetInstance(typeof(Foo));
fooSingleton will have a new meaning.
I think the answer probably relies on actually clearing the directory and then updating it - but that seems redundant for such a simple thing.
source
share