Getting an export from an MEF container given only a Type instance

后端 未结 2 386
灰色年华
灰色年华 2020-12-30 07:25

I have a scenario where I have to get an export from my CompositionContainer instance but I only have a Type to work with; I don\'t know the type at compile time, hence I ca

2条回答
  •  一生所求
    2020-12-30 07:47

    Found the answer:

    var export = _container.GetExports(someType, null, null).FirstOrDefault();
    

提交回复
热议问题