private static AggregateCatalog LoadConfiguration(ComponentsSection componentsSection) { // Setup the catalog AggregateCatalog catalog = new AggregateCatalog(); // Get the configuration section if(componentsSection == null) { return catalog; } // Load the catalogs foreach(CatalogElement catalogElement in componentsSection.Catalogs) { // TODO: Log or otherwise record TargetInvocationExceptions catalog.Catalogs.Add(Activator.CreateInstance(catalogElement.SpecifiedType) as ComposablePartCatalog); } // Load the directories // TODO: Add Search Pattern parameter to DirectoryElement foreach(DirectoryElement directoryElement in componentsSection.Directories) { catalog.Catalogs.Add(new DirectoryCatalog(directoryElement.Directory)); } // Load the assemblies foreach(AssemblyInfo assemblyElement in componentsSection.Assemblies) { // Load the assembly by partial name Assembly asm = Assembly.Load(assemblyElement.Assembly); // Add a new AssemblyCatalog to the aggregate if(asm != null) { catalog.Catalogs.Add(new AssemblyCatalog(asm)); } } // Load the types if (componentsSection.Types.Count > 0) { catalog.Catalogs.Add(new TypeCatalog((from typeElement in componentsSection.Types.OfType<TypeElement>() where typeElement.SpecifiedType != null select typeElement.SpecifiedType))); } return catalog; }
public ConfiguredCatalog(ComponentsSection configurationSection) { _configurationSection = configurationSection; }
public ConfiguredCatalog(string configurationSectionName) { Arg.NotNullOrEmpty("configurationSectionName", configurationSectionName); _configurationSection = ConfigurationManager.GetSection(configurationSectionName) as ComponentsSection; }