Пример #1
0
 public void SetupSingleFactory()
 {
     var catalog = new TypeCatalog(typeof (PartA), typeof(PartThatUsesAFactory));
     var ep = new ExportFactoryProvider();
     _container = new CompositionContainer(catalog, ep);
     ep.SourceProvider = _container;
 }
Пример #2
0
 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;
 }
Пример #3
0
 protected override CompositionContainer CreateContainer()
 {
     var exportFactoryProvider = new ExportFactoryProvider();
     var container = new CompositionContainer(this.AggregateCatalog, exportFactoryProvider);
     exportFactoryProvider.SourceProvider = container;
     return container;
 }
Пример #4
0
        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();
        }
Пример #5
0
        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);
        }