星空网 > 软件开发 > ASP.net

MEF example code

 

public interface IObjectResolver  {  }public class ObjectResolver:IObjectResolver  {   private CompositionContainer container;   public ObjectResolver()   {     container = new CompositionContainer(new AggregateCatalog());   }   public void AddCatalogFile(string fileName)   {     if (!File.Exists(fileName))       throw new FileNotFoundException();     AggregateCatalog catalog = (AggregateCatalog)container.Catalog;     catalog.Catalogs.Add(new AssemblyCatalog(fileName));     container.ComposeParts();   }   public T GetExport<T>(string name)   {     return container.GetExportedValue<T>(name);   }  }




原标题:MEF example code

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流