Adding an instance to a MEF container

前端 未结 1 1244
臣服心动
臣服心动 2021-02-19 02:14

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<

相关标签:
1条回答
  • 2021-02-19 02:27

    You can use the ComposeExportedValue function for this, like so:

    var container = new CompositionContainer();
    container.ComposeExportedValue<Application>("Application", Application.Current);
    
    0 讨论(0)
提交回复
热议问题