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


C# CompositionContainer.ComposeExportedValue方法代码示例

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


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

示例1: WhenInitializingAModuleWithNoCatalogPendingToBeLoaded_ThenInitializesTheModule

        public void WhenInitializingAModuleWithNoCatalogPendingToBeLoaded_ThenInitializesTheModule()
        {
            var aggregateCatalog = new AggregateCatalog(new AssemblyCatalog(typeof(MefModuleInitializer).Assembly));
            var compositionContainer = new CompositionContainer(aggregateCatalog);
            compositionContainer.ComposeExportedValue(aggregateCatalog);

            var serviceLocatorMock = new Mock<IServiceLocator>();
            var loggerFacadeMock = new Mock<ILoggerFacade>();

            var serviceLocator = serviceLocatorMock.Object;
            var loggerFacade = loggerFacadeMock.Object;

            compositionContainer.ComposeExportedValue(serviceLocator);
            compositionContainer.ComposeExportedValue(loggerFacade);

            aggregateCatalog.Catalogs.Add(new TypeCatalog(typeof(TestModuleForInitializer)));

            var moduleInitializer = compositionContainer.GetExportedValue<IModuleInitializer>();

            var moduleInfo = new ModuleInfo("TestModuleForInitializer", typeof(TestModuleForInitializer).AssemblyQualifiedName);

            var module = compositionContainer.GetExportedValues<IModule>().OfType<TestModuleForInitializer>().First();

            Assert.IsFalse(module.Initialized);

            moduleInitializer.Initialize(moduleInfo);

            Assert.IsTrue(module.Initialized);
        }
开发者ID:Citringo,项目名称:Prism,代码行数:29,代码来源:MefModuleInitializerFixture.cs

示例2: ModuleInUnreferencedAssemblyInitializedByModuleInitializer

        public void ModuleInUnreferencedAssemblyInitializedByModuleInitializer()
        {
            AssemblyCatalog assemblyCatalog = new AssemblyCatalog(GetPathToModuleDll());
            CompositionContainer compositionContainer = new CompositionContainer(assemblyCatalog);

            ModuleCatalog moduleCatalog = new ModuleCatalog();

            Mock<MefFileModuleTypeLoader> mockFileTypeLoader = new Mock<MefFileModuleTypeLoader>();

            compositionContainer.ComposeExportedValue<IModuleCatalog>(moduleCatalog);
            compositionContainer.ComposeExportedValue<MefFileModuleTypeLoader>(mockFileTypeLoader.Object);

            bool wasInit = false;
            var mockModuleInitializer = new Mock<IModuleInitializer>();
            mockModuleInitializer.Setup(x => x.Initialize(It.IsAny<ModuleInfo>())).Callback(() => wasInit = true);

            var mockLoggerFacade = new Mock<ILoggerFacade>();

            MefModuleManager moduleManager = new MefModuleManager(
                mockModuleInitializer.Object,
                moduleCatalog,
                mockLoggerFacade.Object);

            compositionContainer.SatisfyImportsOnce(moduleManager);

            moduleManager.Run();

            Assert.IsTrue(wasInit);
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:29,代码来源:MefModuleManagerFixture.Desktop.cs

示例3: Initialize

    protected override void Initialize()
    {
        base.Initialize();

        var exceptionDialog = new ExceptionDialog("http://code.google.com/p/notifypropertyweaver/issues/list", "NotifyPropertyWeaver");
        try
        {
            using (var catalog = new AssemblyCatalog(GetType().Assembly))
            using (var container = new CompositionContainer(catalog))
            {
                var menuCommandService = (IMenuCommandService) GetService(typeof (IMenuCommandService));
                var errorListProvider = new ErrorListProvider(ServiceProvider.GlobalProvider);

                container.ComposeExportedValue(exceptionDialog);
                container.ComposeExportedValue(menuCommandService);
                container.ComposeExportedValue(errorListProvider);

                container.GetExportedValue<MenuConfigure>().RegisterMenus();
                container.GetExportedValue<SolutionEvents>().RegisterSolutionEvents();
                container.GetExportedValue<TaskFileReplacer>().CheckForFilesToUpdate();
            }
        }
        catch (Exception exception)
        {
            exceptionDialog.HandleException(exception);
        }
    }
开发者ID:shiftkey,项目名称:NotifyPropertyWeaver,代码行数:27,代码来源:NotifyPropertyWeaverVsPackagePackage.cs

示例4: WhenInitializingAModuleWithACatalogPendingToBeLoaded_ThenLoadsTheCatalogInitializesTheModule

        public void WhenInitializingAModuleWithACatalogPendingToBeLoaded_ThenLoadsTheCatalogInitializesTheModule()
        {
            var aggregateCatalog = new AggregateCatalog(new AssemblyCatalog(typeof(MefModuleInitializer).Assembly));
            var compositionContainer = new CompositionContainer(aggregateCatalog);
            compositionContainer.ComposeExportedValue(aggregateCatalog);

            var serviceLocatorMock = new Mock<IServiceLocator>();
            var loggerFacadeMock = new Mock<ILoggerFacade>();

            var serviceLocator = serviceLocatorMock.Object;
            var loggerFacade = loggerFacadeMock.Object;

            compositionContainer.ComposeExportedValue(serviceLocator);
            compositionContainer.ComposeExportedValue(loggerFacade);

            var moduleInitializer = compositionContainer.GetExportedValue<IModuleInitializer>();
            var repository = compositionContainer.GetExportedValue<DownloadedPartCatalogCollection>();

            var moduleInfo = new ModuleInfo("TestModuleForInitializer", typeof(TestModuleForInitializer).AssemblyQualifiedName);

            repository.Add(moduleInfo, new TypeCatalog(typeof(TestModuleForInitializer)));

            moduleInitializer.Initialize(moduleInfo);

            ComposablePartCatalog existingCatalog;
            Assert.IsFalse(repository.TryGet(moduleInfo, out existingCatalog));

            var module = compositionContainer.GetExportedValues<IModule>().OfType<TestModuleForInitializer>().First();

            Assert.IsTrue(module.Initialized);
        }
开发者ID:Citringo,项目名称:Prism,代码行数:31,代码来源:MefModuleInitializerFixture.cs

示例5: 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

示例6: Start

 public void Start()
 {
     _documentStore = new EmbeddableDocumentStore
     {
         DataDirectory = "./continuity.db",
         UseEmbeddedHttpServer = true,
     };
     _documentStore.Initialize();
     var container = new CompositionContainer(
                  new AggregateCatalog(
                      new AssemblyCatalog(GetType().Assembly),
                     new AssemblyCatalog(typeof(IBus).Assembly),
                     new DirectoryCatalog("extensions")
                  ));
     container.ComposeExportedValue<IDocumentStore>(_documentStore);
     container.ComposeExportedValue<IDocumentSession>(_documentStore.OpenSession());
     container.ComposeExportedValue<IBus>(new StandardBus());
     container.ComposeParts(this);
     _kernel.Bind<IDocumentStore>().ToConstant(_documentStore);
     _kernel.Bind<IDocumentSession>().ToMethod(c => _documentStore.OpenSession());
     //var startupTasks = _kernel.GetAll<INeedToRunAtStartup>();
     foreach (var task in StartupItems)
         task.Run();
     HttpServer.Start();
     var config = _kernel.Get<ContinuityConfiguration>();
     _serverAddress = "localhost";
     _serverPort = config.Port.ToString();
 }
开发者ID:caseykramer,项目名称:Continuity,代码行数:28,代码来源:Bootstrapper.cs

示例7: Prepare

 public void Prepare()
 {
     container = new CompositionContainer(
         new AggregateCatalog(
             new AssemblyCatalog(
                 typeof (ITypedPool).Assembly
                 ),
             new TypeCatalog(typeof (Registrator)),
             new TypeCatalog(typeof(ResourcePool)),
             new TypeCatalog(typeof (NotifiedElementGetter)),
             new TypeCatalog(typeof (UnnotifiedElementGetter)),
             new TypeCatalog(typeof (NotifiedElementPoster)),
             new TypeCatalog(typeof (UnnotifiedElementPoster))));
     _uplink = _mockRepository.DynamicMock<AnnouncerUplink>();
     _downlink = _mockRepository.DynamicMock<AnnouncerDownlink>(); 
     _downlink.Expect(k => k.Subscribe(null))                   
            .IgnoreArguments()
            .Repeat.Once();
     _downlink.Replay();
     
     container.ComposeExportedValue(_uplink);
     container.ComposeExportedValue(_downlink);
     var service = container.GetExportedValue<ICacheServicing>(); 
     service.Initialize(new Settings
                            {
                                AutoSubscription = (TestContext.Properties["AutoSubscription"] as string)== "true"                                      
                            }, container);
     _pool = container.GetExportedValue<ITypedPool>();
     _subscriptor = container.GetExportedValue<IAnnouncerSubscriptor>();                        
 }
开发者ID:kayanme,项目名称:Dataspace,代码行数:30,代码来源:NotifyTest.cs

示例8: UnknownExportedModuleIsAddedAndInitializedByModuleInitializer

        public void UnknownExportedModuleIsAddedAndInitializedByModuleInitializer()
        {
            var aggregateCatalog = new AggregateCatalog();
            var compositionContainer = new CompositionContainer(aggregateCatalog);

            var moduleCatalog = new ModuleCatalog();

            var mockModuleTypeLoader = new Mock<MefXapModuleTypeLoader>(new DownloadedPartCatalogCollection());

            compositionContainer.ComposeExportedValue<IModuleCatalog>(moduleCatalog);
            compositionContainer.ComposeExportedValue<MefXapModuleTypeLoader>(mockModuleTypeLoader.Object);

            bool wasInit = false;
            var mockModuleInitializer = new Mock<IModuleInitializer>();
            mockModuleInitializer.Setup(x => x.Initialize(It.IsAny<ModuleInfo>())).Callback(() => wasInit = true);

            var mockLoggerFacade = new Mock<ILoggerFacade>();

            var moduleManager =
                new MefModuleManager(mockModuleInitializer.Object, moduleCatalog, mockLoggerFacade.Object);

            aggregateCatalog.Catalogs.Add(new TypeCatalog(typeof(TestMefModule)));

            compositionContainer.SatisfyImportsOnce(moduleManager);

            moduleManager.Run();

            Assert.IsTrue(wasInit);
            Assert.IsTrue(moduleCatalog.Modules.Any(mi => mi.ModuleName == "TestMefModule"));
        }
开发者ID:CarlosVV,项目名称:mediavf,代码行数:30,代码来源:MefModuleManagerFixture.Silverlight.cs

示例9: Preparation

 public void Preparation()
 {
     container = MockHelper.InitializeContainer(new[] { typeof(IProjectionsCollector).Assembly, typeof(Element).Assembly }, new Type[0]);           
     var pool = new ResourcePool();           
     container.ComposeExportedValue(pool);
     container.ComposeExportedValue(container);
     Settings.NoCacheGarbageChecking = true;
 }
开发者ID:kayanme,项目名称:Dataspace,代码行数:8,代码来源:Tests.cs

示例10: Run

 public virtual void Run()
 {
     Container = new CompositionContainer(new AggregateCatalog(Catalogs));
     var mefServiceLocator = new MEFServiceLocator(Container);
     ServiceLocator.SetProvider(() => mefServiceLocator);
     Container.ComposeExportedValue(Container);
     Container.ComposeExportedValue(ServiceLocator.Current);
     ApplicationLoaded();
 }
开发者ID:arbium,项目名称:democratia2,代码行数:9,代码来源:AbstractBootstrapper.cs

示例11: SetupCompositionContainer

		private CompositionContainer SetupCompositionContainer()
		{
			var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
			var container = new CompositionContainer(catalog);
			container.ComposeExportedValue<BootstrapperApplication>(this);
			container.ComposeExportedValue<Engine>(this.Engine);
			container.ComposeExportedValue<IUIInteractionService>(this);
			return container;
		}
开发者ID:mkandroid15,项目名称:Samples,代码行数:9,代码来源:InstallerUIBootstrapper.cs

示例12: CompositionHost

 /// <summary>
 /// Initializes a new instance of the <see cref="CompositionHost" /> class.
 /// </summary>
 /// <param name="isThreadSafe">if set to <c>true</c> if the container is thread safe.</param>
 public CompositionHost(bool isThreadSafe)
 {
     var catalog = new AggregateCatalog();
     Contract.Assume(catalog.Catalogs != null);
     _container = new CompositionContainer(catalog, isThreadSafe);
     _container.ComposeExportedValue((ICompositionHost)this);
     _container.ComposeExportedValue((IServiceProvider)this);
     _container.ComposeExportedValue((ExportProvider)Container);
 }
开发者ID:tom-englert,项目名称:TomsToolbox,代码行数:13,代码来源:CompositionHost.cs

示例13: ApplicationStartup

        protected virtual void ApplicationStartup(object sender, StartupEventArgs e)
        {
            Catalog = new AggregateCatalog(
                new AssemblyCatalog(typeof(AppBase).Assembly)
                );
            Container = new CompositionContainer(Catalog);

            Container.ComposeExportedValue(new ViewFactory(Container));
            Container.ComposeExportedValue(new StateHandler(Container));
        }
开发者ID:davidbitton,项目名称:MvvmUtility,代码行数:10,代码来源:AppBase.cs

示例14: Preparation

 public void Preparation()
 {
     container = MockHelper.InitializeContainer(new[] { typeof(IProjectionsCollector).Assembly, typeof(Element).Assembly }, new Type[0]);
     var pool = new ResourcePool();
     var writer = new TestWriter();
     container.ComposeExportedValue(container);
     container.ComposeExportedValue(pool);
     container.ComposeExportedValue(writer);
     container.GetExportedValue<ICacheServicing>().Initialize();
 }
开发者ID:kayanme,项目名称:Dataspace,代码行数:10,代码来源:PlanLoaderTest.cs

示例15: Application_Start

 protected void Application_Start(object sender, EventArgs e)
 {
     var assembly = new AssemblyCatalog(typeof(Global).Assembly); //this is how to add curent assembly
     var catalog = new AggregateCatalog();
     catalog.Catalogs.Add(assembly);
     catalog.Catalogs.Add(new DirectoryCatalog("bin")); //this is where our DLLs are located. "." is for WPF app, "bin" is for WEB app
     var container = new CompositionContainer(catalog);
     var mefServiceLocator = new MefServiceLocator(container);
     ServiceLocator.SetLocatorProvider(() => mefServiceLocator);
     container.ComposeExportedValue<IServiceLocator>(mefServiceLocator);
     container.ComposeExportedValue(container);
 }
开发者ID:BazhenovIgor,项目名称:wcf-seminars-2015,代码行数:12,代码来源:Global.asax.cs


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