标签:
How can you add an already created instance to a MEF container/cataloge to use when resolving Imports. I want the functionality that Unity gives with the RegisterInstance
method on its containers.
You can use the ComposeExportedValue function for this, like so:
var container = new CompositionContainer(); container..ComposeExportedValue<IConfigFileInvoker>(new ConfigFileInvoker());
container..ComposeExportedValue<IConfigFileInvoker>("export-string",new ConfigFileInvoker());
Adding an instance to a MEF container
标签:
原文地址:http://www.cnblogs.com/zjoch/p/4579603.html