private void LoadRegistriesFromCatalog() { using (var ep = new CatalogExportProvider(this.decoratedCatalog)) { ep.SourceProvider = ep; var registries = ep.GetExportedValues <IGenericContractRegistry>(); LoadTypeMappings(registries); } }
/// <summary> /// 从当前目录下的所有程序集中加载所有实现 <see cref="IExportTargeterControlFactory"/> 接口的实例 /// </summary> public IList <IExportTargeterControlFactory> LoadIExportTargeterControlFactorys() { var providers = new List <IExportTargeterControlFactory>(); String directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); DirectoryCatalog catalog = new DirectoryCatalog(directory, SearchPattern); using (CatalogExportProvider exportProvider = new CatalogExportProvider(catalog)) { exportProvider.SourceProvider = exportProvider; var exports = exportProvider.GetExportedValues <IExportTargeterControlFactory>(); providers.AddRange(exports); } this.ExportTargeterControlFactorys = providers; return(providers); }
/// <summary> /// 从当前目录下的所有程序集中加载所有实现 <see cref="ISchemaProvider"/> 接口的实例 /// </summary> public IList <ISchemaProvider> LoadSchemProviders(Boolean isCached = true) { List <ISchemaProvider> providers = new List <ISchemaProvider>(); #if NET40 String directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); DirectoryCatalog catalog = new DirectoryCatalog(directory, SearchPattern); using (CatalogExportProvider exportProvider = new CatalogExportProvider(catalog)) { exportProvider.SourceProvider = exportProvider; var exports = exportProvider.GetExportedValues <ISchemaProvider>(); providers.AddRange(exports); } #endif #if NETSTANDARD2_0 var convention = new ConventionBuilder(); var part = convention.ForTypesDerivedFrom <ISchemaProvider>().Export(); String directory = AppDomain.CurrentDomain.BaseDirectory; String[] files = Directory.GetFiles(directory, SearchPattern); if (files.Length > 0) { List <Assembly> assemblies = new List <Assembly>(); foreach (String file in files) { var assembly = Assembly.LoadFile(file); assemblies.Add(assembly); } var configuration = new ContainerConfiguration(); configuration.WithAssemblies(assemblies); var container = configuration.CreateContainer(); var exports = container.GetExports <ISchemaProvider>(); providers.AddRange(exports); } #endif this.SchemaProviders = providers; return(providers); }