1:新建一个主题工程MEFOwn

2:新建一个接口DLL,定义为InterFace,

3:新建插件,引用这个接口,以及微软的ComponentModel.Composition

4:   调整命名空间,保持一致

5:插件处导出 [Export(typeof(IPlugin))],  实现接口

6:主工程处,引用接口,引用微软的ComponentModel.Composition

本身作为一个容器,将目录下所有的插件DLL,都加载到容器中

CompsitionContainer _container;

var catalog = new AggregateCatalog();

.....Add  

this._container.ComposeParts(this)

 

      [ImportMany]

      public IEnumerable<IPlugin> plugins;

    

 

相关文章:

  • 2021-09-30
  • 2021-10-31
  • 2021-12-03
  • 2021-10-13
  • 2022-12-23
猜你喜欢
  • 2022-01-17
  • 2021-06-26
  • 2021-09-16
  • 2021-11-18
  • 2021-04-15
相关资源
相似解决方案