private void InitializeCompositionContainer() { if (!Directory.Exists("Plugins")) { Directory.CreateDirectory("Plugins"); } var catalog = new AggregatingComposablePartCatalog(); catalog.Catalogs.Add(new DirectoryPartCatalog("Plugins", true)); catalog.Catalogs.Add(new AttributedAssemblyPartCatalog(typeof(MonitorManager).Assembly)); catalog.Catalogs.Add(new AttributedAssemblyPartCatalog(Assembly.GetExecutingAssembly())); container = new CompositionContainer(catalog.CreateResolver()); container.AddPart(this); //container.AddExportedObject<ICompositionService>(container); //container.AddExportedObject<AggregatingComposablePartCatalog>(catalog); try { container.Compose(); } catch (CompositionException compositionException) { MessageBox.Show(compositionException.ToString()); } }
/// <summary> /// use managed extensibility framework to discover effects and load them into the main form /// </summary> private void Compose() { var catalog = new AggregatingComposablePartCatalog(); var mainAssemblyCatalog = new AttributedAssemblyPartCatalog(this.GetType().Assembly); var jsNetCatalog = new AttributedAssemblyPartCatalog(typeof(Effect).Assembly); //var addInEffects = new DirectoryPartCatalog("Effects"); catalog.Catalogs.Add(mainAssemblyCatalog); catalog.Catalogs.Add(jsNetCatalog); //catalog.Catalogs.Add(addInEffects); var container = new CompositionContainer(catalog); container.AddPart(this); container.Compose(); }
public HelloProgram() { this.Services = new List<IHelloService>(); if (!Directory.Exists("PlugIns")) { Directory.CreateDirectory("PlugIns"); } AggregatingComposablePartCatalog catalog = new AggregatingComposablePartCatalog(); catalog.Catalogs.Add(new AttributedAssemblyPartCatalog(Assembly.GetExecutingAssembly())); catalog.Catalogs.Add(new DirectoryPartCatalog("PlugIns")); CompositionContainer container = new CompositionContainer(catalog.CreateResolver()); container.AddPart(this); container.Compose(); }
public HelloProgram() { this.Services = new List <IHelloService>(); if (!Directory.Exists("PlugIns")) { Directory.CreateDirectory("PlugIns"); } AggregatingComposablePartCatalog catalog = new AggregatingComposablePartCatalog(); catalog.Catalogs.Add(new AttributedAssemblyPartCatalog(Assembly.GetExecutingAssembly())); catalog.Catalogs.Add(new DirectoryPartCatalog("PlugIns")); CompositionContainer container = new CompositionContainer(catalog.CreateResolver()); container.AddPart(this); container.Compose(); }