当前位置: 首页>>代码示例>>C#>>正文


C# CompositionContainer.GetExport方法代码示例

本文整理汇总了C#中System.ComponentModel.Composition.Hosting.CompositionContainer.GetExport方法的典型用法代码示例。如果您正苦于以下问题:C# CompositionContainer.GetExport方法的具体用法?C# CompositionContainer.GetExport怎么用?C# CompositionContainer.GetExport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ComponentModel.Composition.Hosting.CompositionContainer的用法示例。


在下文中一共展示了CompositionContainer.GetExport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InteractiveWindowTestHost

        internal InteractiveWindowTestHost()
        {
            _exportProvider = new CompositionContainer(
                s_lazyCatalog.Value,
                CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe);

            var contentTypeRegistryService = _exportProvider.GetExport<IContentTypeRegistryService>().Value;
            Evaluator = new TestInteractiveEvaluator();
            Window = _exportProvider.GetExport<IInteractiveWindowFactoryService>().Value.CreateWindow(Evaluator);
            Window.InitializeAsync().Wait();
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:InteractiveWindowTestHost.cs

示例2: InteractiveWindowTestHost

        internal InteractiveWindowTestHost(Action<InteractiveWindow.State> stateChangedHandler = null)
        {
            ExportProvider = new CompositionContainer(
                s_lazyCatalog.Value,
                CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe);

            var contentTypeRegistryService = ExportProvider.GetExport<IContentTypeRegistryService>().Value;
            Evaluator = new TestInteractiveEngine(contentTypeRegistryService);
            Window = ExportProvider.GetExport<IInteractiveWindowFactoryService>().Value.CreateWindow(Evaluator);
            ((InteractiveWindow)Window).StateChanged += stateChangedHandler;
            Window.InitializeAsync().Wait();
        }
开发者ID:orthoxerox,项目名称:roslyn,代码行数:12,代码来源:InteractiveWindowTestHost.cs

示例3: MainWindow

        public MainWindow() {
            InitializeComponent();

            EnvironmentsToolWindow.ViewCreated += EnvironmentsToolWindow_ViewCreated;

            _container = new CompositionContainer(new AggregateCatalog(
                new AssemblyCatalog(typeof(IInterpreterRegistryService).Assembly),
                new AssemblyCatalog(typeof(IInterpreterOptionsService).Assembly)
            ));

            EnvironmentsToolWindow.Interpreters = _container.GetExport<IInterpreterRegistryService>().Value;
            EnvironmentsToolWindow.Service = _container.GetExport<IInterpreterOptionsService>().Value;
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:13,代码来源:MainWindow.xaml.cs

示例4: InteractiveWindowTestHost

        internal InteractiveWindowTestHost(Action<InteractiveWindow.State> stateChangedHandler = null)
        {
            SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());

            _exportProvider = new CompositionContainer(
                _lazyCatalog.Value,
                CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe);

            var contentTypeRegistryService = _exportProvider.GetExport<IContentTypeRegistryService>().Value;
            _window = _exportProvider.GetExport<IInteractiveWindowFactoryService>().Value.CreateWindow(new TestInteractiveEngine(contentTypeRegistryService));
            ((InteractiveWindow)_window).StateChanged += stateChangedHandler;
            _window.InitializeAsync().PumpingWait();
        }
开发者ID:noahstein,项目名称:roslyn,代码行数:13,代码来源:InteractiveWindowTestHost.cs

示例5: InteractiveWindowTestHost

        public InteractiveWindowTestHost()
        {
            SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());

            var types = new[] { typeof(TestInteractiveEngine), typeof(InteractiveWindow) }.Concat(GetVisualStudioTypes());
            _exportProvider = new CompositionContainer(
                new AggregateCatalog(types.Select(t => new AssemblyCatalog(t.Assembly))),
                CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe);

            var contentTypeRegistryService = _exportProvider.GetExport<IContentTypeRegistryService>().Value;
            _window = _exportProvider.GetExport<IInteractiveWindowFactoryService>().Value.CreateWindow(new TestInteractiveEngine(contentTypeRegistryService));

            _window.InitializeAsync().PumpingWait();
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:14,代码来源:InteractiveWindowTestHost.cs

示例6: Start

        public void Start()
        {
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(SearchDemo).Assembly));
            var container = new CompositionContainer(catalog);
            container.ComposeParts();

            try
            {
                var component = container.GetExport<ITestComponent>();
                if (component != null)
                    Console.WriteLine(component.Value.Message);
            }
            catch (Exception exp)
            {
                //Why does our call to 'GetExport' throw an exception?

                //Search for the string "Test" on the container variable
                //You'll find 3 instances in the Catalog.
                //Then search for ITestComponent.
                //You'll need to click "Search Deeper" to expand the search.

                //Another way to do this is to view "container.Catalog.Parts", right click it,
                //select 'Edit Filter' and enter the following predicate:
                //         [obj].Exports(typoef(ITestComponent)

                MessageBox.Show(exp.Message, "Exception caught!");
            }
        }
开发者ID:OmerRaviv,项目名称:OzCodeDemo,代码行数:30,代码来源:SearchDemo.cs

示例7: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
            catalog.Catalogs.Add(new DirectoryCatalog("."));

            var container = new CompositionContainer(catalog);

            try
            {
                container.ComposeParts(this);
                container.ComposeExportedValue("container", container);

                Lazy<IModuleController> controller = container.GetExport<IModuleController>();
                if (controller == null) return;

                controller.Value.CompositionContainer = container;
                controller.Value.Run();
            }
            catch (CompositionException exception)
            {
                MessageBox.Show(exception.ToString());
            }
        }
开发者ID:HASystem,项目名称:HASystem,代码行数:26,代码来源:App.xaml.cs

示例8: Main

		static void Main()
		{
            var engine = new GUILayer.EngineDevice();
            GC.KeepAlive(engine);

            var catalog = new TypeCatalog(
                typeof(ShaderPatcherLayer.Manager),
                typeof(ShaderFragmentArchive.Archive),
                typeof(NodeEditorCore.ShaderFragmentArchiveModel),
                typeof(NodeEditorCore.ModelConversion),
                typeof(NodeEditorCore.ShaderFragmentNodeCreator),
                typeof(NodeEditorCore.DiagramDocument),
                typeof(ExampleForm)
            );

            using (var container = new CompositionContainer(catalog))
            {
                container.ComposeExportedValue<ExportProvider>(container);
                container.ComposeExportedValue<CompositionContainer>(container);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(container.GetExport<ExampleForm>().Value);
            }

            engine.Dispose();
		}
开发者ID:coreafive,项目名称:XLE,代码行数:27,代码来源:Program.cs

示例9: LoadServer

        public static ServerEntry LoadServer(string path)
        {
            try
            {
                //  Create a server entry for the server.
                var serverEntry = new ServerEntry();

                //  Set the data.
                serverEntry.ServerName = Path.GetFileNameWithoutExtension(path);
                serverEntry.ServerPath = path;

                //  Create an assembly catalog for the assembly and a container from it.
                var catalog = new AssemblyCatalog(Path.GetFullPath(path));
                var container = new CompositionContainer(catalog);

                //  Get the exported server.
                var server = container.GetExport<ISharpShellServer>().Value;

                serverEntry.ServerType = server.ServerType;
                serverEntry.ClassId = server.GetType().GUID;
                serverEntry.Server = server;

                return serverEntry;
            }
            catch (Exception)
            {
                //  It's almost certainly not a COM server.
                MessageBox.Show("The file '" + Path.GetFileName(path) + "' is not a SharpShell Server.", "Warning");
                return null;
            }
        }
开发者ID:xieguigang,项目名称:Reference_SharedLib,代码行数:31,代码来源:ServerManagerApi.cs

示例10: GetValuesByType

        public void GetValuesByType()
        {
            var cat = CatalogFactory.CreateDefaultAttributed();

            var container = new CompositionContainer(cat);

            string itestName = AttributedModelServices.GetContractName(typeof(ITest));

            var e1 = container.GetExportedValues<ITest>();
            var e2 = container.GetExports<ITest, object>(itestName);

            Assert.IsInstanceOfType(e1.First(), typeof(T1), "First should be T1");
            Assert.IsInstanceOfType(e1.Skip(1).First(), typeof(T2), "Second should be T2");

            Assert.IsInstanceOfType(e2.First().Value, typeof(T1), "First should be T1");
            Assert.IsInstanceOfType(e2.Skip(1).First().Value, typeof(T2), "Second should be T2");

            CompositionContainer childContainer = new CompositionContainer(container);
            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(new T1());
            container.Compose(batch);
            var t1 = childContainer.GetExportedValue<ITest>();
            var t2 = childContainer.GetExport<ITest, object>(itestName);

            Assert.IsInstanceOfType(t1, typeof(T1), "First (resolved) should be T1");
            Assert.IsInstanceOfType(t2.Value, typeof(T1), "First (resolved) should be T1");
        }
开发者ID:nlhepler,项目名称:mono,代码行数:27,代码来源:ComponentServicesTests.cs

示例11: CanMakeSweetShopWithVanillaJellybeans

        public void CanMakeSweetShopWithVanillaJellybeans()
        {
            TypeCatalog catalog = new TypeCatalog(typeof(VanillaJellybeanDispenser), typeof(SweetVendingMachine), typeof(SweetShop));
            CompositionContainer container = new CompositionContainer(catalog);

            SweetShop sweetShop = container.GetExport<SweetShop>().Value;

            Assert.AreEqual(Jellybean.Vanilla, sweetShop.DispenseJellyBean());
        }
开发者ID:AnthonySteele,项目名称:IoCComparison,代码行数:9,代码来源:MEFTests.cs

示例12: CanMakeAniseedRootObject

        public void CanMakeAniseedRootObject()
        {
            TypeCatalog catalog = new TypeCatalog(typeof(AniseedSweetShop));
            CompositionContainer container = new CompositionContainer(catalog);

            SweetShop sweetShop = container.GetExport<SweetShop>().Value;

            Assert.AreEqual(Jellybean.Aniseed, sweetShop.DispenseJellyBean());
        }
开发者ID:AnthonySteele,项目名称:IoCComparison,代码行数:9,代码来源:MEFTests.cs

示例13: ClassExportsITemplateEditorOptionsForConsumptionByEditorClasses

 public void ClassExportsITemplateEditorOptionsForConsumptionByEditorClasses()
 {
     using (var catalog = new TypeCatalog(typeof(T4ToolboxOptions)))
     using (var container = new CompositionContainer(catalog))
     {
         Lazy<ITemplateEditorOptions> export = container.GetExport<ITemplateEditorOptions>();
         Assert.IsInstanceOfType(export.Value, typeof(T4ToolboxOptions));
     }
 }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:9,代码来源:T4ToolboxOptionsTest.cs

示例14: SimpleExport_part_with_metadata_is_properly_exported

        public void SimpleExport_part_with_metadata_is_properly_exported()
        {
            var registry = new ConfigurationPartRegistry("mef.configuration");
            var catalog = new ConventionCatalog(registry);
            var container = new CompositionContainer(catalog);

            var simpleExport = container.GetExport<SimpleExportWithMetadata, ISimpleMetadata>("simple-export");
            Assert.That(simpleExport, Is.Not.Null);
            Assert.That(simpleExport.Metadata.IntValue, Is.EqualTo(1234));
            Assert.That(simpleExport.Metadata.StrValue, Is.EqualTo("some string"));
        }
开发者ID:doublekill,项目名称:MefContrib,代码行数:11,代码来源:ConfigurationPartRegistryIntegrationTests.cs

示例15: TypeCatalog

        public void ContainerCanGetExportForSauceBéarnaise()
        {
            var catalog = new TypeCatalog(typeof(Ploeh.Samples.Menu.Mef.Attributed.Unmodified.Concrete.SauceBéarnaise));
            var container = new CompositionContainer(catalog);

            Lazy<SauceBéarnaise> export =
                container.GetExport<SauceBéarnaise>();
            SauceBéarnaise sauce = export.Value;

            Assert.NotNull(sauce);
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:11,代码来源:MenuFacts.cs


注:本文中的System.ComponentModel.Composition.Hosting.CompositionContainer.GetExport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。