public void SetupSingleFactory() { var catalog = new TypeCatalog(typeof (PartA), typeof(PartThatUsesAFactory)); var ep = new ExportFactoryProvider(); _container = new CompositionContainer(catalog, ep); ep.SourceProvider = _container; }
public void SetupMultipleFactories() { var catalog = new TypeCatalog(typeof(PartA), typeof(PartB), typeof(PartThatUsesACollectionOfFactories)); var ep = new ExportFactoryProvider(); _container = new CompositionContainer(catalog, ep); ep.SourceProvider = _container; }
protected override CompositionContainer CreateContainer() { var exportFactoryProvider = new ExportFactoryProvider(); var container = new CompositionContainer(this.AggregateCatalog, exportFactoryProvider); exportFactoryProvider.SourceProvider = container; return container; }
protected override CompositionContainer CreateContainer() { var exportFactoryProvider = new ExportFactoryProvider(); var container = new CompositionContainer(this.AggregateCatalog, exportFactoryProvider); exportFactoryProvider.SourceProvider = container; return container; //var debugger = new MefDebugger(container); //container.ComposeParts(this); //debugger.Close(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var catalog = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()); var exportFactoryProvider = new ExportFactoryProvider(); // enable use of ExportFactory var container = new CompositionContainer(catalog, exportFactoryProvider); exportFactoryProvider.SourceProvider = container; // enable use of ExportFactory var mainForm = container.GetExportedValue<MainForm>(); Application.Run(mainForm); }