Adding an instance to a MEF container

前端 未结 1 1245
臣服心动
臣服心动 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.Current);
    

    0 讨论(0)
提交回复
热议问题