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


C# CompositionContainer.GetExportedValue方法代码示例

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


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

示例1: Document

        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="catalog"></param>
        /// <param name="exports"></param>
        Document(
            Func<Document, XDocument> xml,
            ComposablePartCatalog catalog,
            ExportProvider exports)
        {
            Contract.Requires<ArgumentNullException>(xml != null);

            // configure composition
            this.configuration = GetConfiguration(catalog, exports);
            this.container = new CompositionContainer(configuration.HostCatalog, true, new CompositionContainer(configuration.GlobalCatalog, true, configuration.Exports));
            this.container.GetExportedValue<DocumentEnvironment>().SetHost(this);

            // required services
            this.invoker = container.GetExportedValue<IInvoker>();
            this.trace = container.GetExportedValue<ITraceService>();

            // initialize xml
            this.xml = xml(this);
            this.xml.AddAnnotation(this);

            // parallel initialization of common interfaces
            Parallel.ForEach(this.xml.DescendantNodesAndSelf(), i =>
            {
                Enumerable.Empty<object>()
                    .Concat(i.Interfaces<IOnInit>())
                    .Concat(i.Interfaces<IOnLoad>())
                    .ToLinkedList();
            });

            // initial invocation entry
            this.invoker.Invoke(() => { });
        }
开发者ID:nxkit,项目名称:nxkit,代码行数:38,代码来源:Document.cs

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

示例3: ApplicationController

        public ApplicationController(CompositionContainer container, IPresentationService presentationService,
            IMessageService messageService, ShellService shellService, ProxyController proxyController, DataController dataController)
        {
            InitializeCultures();
            presentationService.InitializeCultures();

            this.container = container;
            this.dataController = dataController;
            this.proxyController = proxyController;
            this.messageService = messageService;

            this.dataService = container.GetExportedValue<IDataService>();

            this.floatingViewModel = container.GetExportedValue<FloatingViewModel>();
            this.mainViewModel = container.GetExportedValue<MainViewModel>();
            this.userBugsViewModel = container.GetExportedValue<UserBugsViewModel>();
            this.teamBugsViewModel = container.GetExportedValue<TeamBugsViewModel>();

            shellService.MainView = mainViewModel.View;
            shellService.UserBugsView = userBugsViewModel.View;
            shellService.TeamBugsView = teamBugsViewModel.View;

            this.floatingViewModel.Closing += FloatingViewModelClosing;

            this.showMainWindowCommand = new DelegateCommand(ShowMainWindowCommandExcute);
            this.englishCommand = new DelegateCommand(() => SelectLanguage(new CultureInfo("en-US")));
            this.chineseCommand = new DelegateCommand(() => SelectLanguage(new CultureInfo("zh-CN")));
            this.settingCommand = new DelegateCommand(SettingDialogCommandExcute, CanSettingDialogCommandExcute);
            this.aboutCommand = new DelegateCommand(AboutDialogCommandExcute);
            this.exitCommand = new DelegateCommand(ExitCommandExcute);
        }
开发者ID:alibad,项目名称:Bugger,代码行数:31,代码来源:ApplicationController.cs

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

示例5: Main

        static void Main()
        {
            try
            {
               
                programCatalog = new AggregateCatalog();
                programCatalog.Catalogs.Add(new DirectoryCatalog(Directory.GetCurrentDirectory()));
                programCatalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
                programContainer = new CompositionContainer(programCatalog);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ThreadException += new ThreadExceptionEventHandler(Program.otherException);
                Application.Run(programContainer.GetExportedValue<FrmMain>());
            }
            catch (Exception e)
            {
                programContainer.GetExportedValue<FrmMain>().richTextBox1.AppendText("\n" + e.Message);
                string logStr = string.Concat(new string[]
				{
					DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"),
					"\t",
					e.Message,
					"\t",
					e.Source
				});
                FileLog.FileLogOut("Client.log", logStr);
            }
           
        }
开发者ID:TGHGH,项目名称:MesSolution,代码行数:29,代码来源:Program.cs

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

示例7: Main

 static void Main(string[] args)
 {
     var container = new CompositionContainer();
     ComposeBatchOne(container);
     container.GetExportedValue<Bootstrapper>().Run();
     ComposeBatchTwo(container);
     container.GetExportedValue<Bootstrapper>().Run();
 }
开发者ID:mikeminutillo,项目名称:mef-sandbox,代码行数:8,代码来源:Program.cs

示例8: Initialize

 public static void Initialize(TestContext context) {
   _container = SetupServerMefContainer();
   _registry = _container.GetExportedValue<IFileSystemProcessor>();
   _searchEngine = _container.GetExportedValue<ISearchEngine>();
   _searchEngine.FilesLoaded += (sender, result) => _serverReadyEvent.Set();
   _testFile = Utils.GetChromiumTestEnlistmentFile();
   _registry.RegisterFile(new FullPath(_testFile.FullName));
 }
开发者ID:mbbill,项目名称:vs-chromium,代码行数:8,代码来源:TestSearchCode.cs

示例9: Test1

        /// <summary>
        /// 同一コントラクト名・別クラステスト
        /// </summary>
        /// <param name="container"></param>
        private static void Test1(CompositionContainer container)
        {
            // インスタンスを取得する
            var type1 = container.GetExportedValue<ITest1>("test");
            var type2 = container.GetExportedValue<ITest2>("test");

            type1.Execute();
            type2.Execute();
        }
开发者ID:yasu-s,项目名称:MEF-Sample,代码行数:13,代码来源:Program.cs

示例10: CreateTextBuffer

        public static ITextBuffer CreateTextBuffer(CompositionContainer container, string text)
        {
            var contentTypeRegistry = container.GetExportedValue<IContentTypeRegistryService>();
            var contentType = contentTypeRegistry.GetContentType(HlslConstants.ContentTypeName)
                ?? contentTypeRegistry.AddContentType(HlslConstants.ContentTypeName, null);

            var textBufferFactory = container.GetExportedValue<ITextBufferFactoryService>();
            var textBuffer = textBufferFactory.CreateTextBuffer(text, contentType);

            return textBuffer;
        }
开发者ID:tgjones,项目名称:HlslTools,代码行数:11,代码来源:TextBufferUtility.cs

示例11: ContainerResolvesBothAbstractionAndConcreteType

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

            var sauce = container.GetExportedValue<SauceBéarnaise>();
            var ingredient = container.GetExportedValue<IIngredient>();

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

示例12: WhenPartIsNonShared_ThenGetExportGetsDifferent

	public void WhenPartIsNonShared_ThenGetExportGetsDifferent()
	{
		var catalog = new TypeCatalog(typeof(NonSharedFoo));
		var filtered = new FilteringReflectionCatalog(catalog);

		var container = new CompositionContainer(filtered);

		var export1 = container.GetExportedValue<NonSharedFoo>();
		var export2 = container.GetExportedValue<NonSharedFoo>();

		Assert.NotSame(export1, export2);
	}
开发者ID:netfx,项目名称:extensions,代码行数:12,代码来源:FilteringReflectionCatalogSpec.cs

示例13: Configure

        protected override void Configure()
        {
            InitializeApplicationDataDirectory();

            var composeTask = Task.Factory.StartNew(() =>
                {
                    // var aggregateCatalog = new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)));
                    var aggregateCatalog = new AggregateCatalog(new AssemblyCatalog(GetType().Assembly), new AssemblyCatalog(typeof(AutoCaptureEngine).Assembly), new AssemblyCatalog(typeof(IRepository<>).Assembly));
                    Container = new CompositionContainer(aggregateCatalog);
                    var batch = new CompositionBatch();
                    batch.AddExportedValue(Container);
                    batch.AddExportedValue<IEventAggregator>(new EventAggregator());
                    batch.AddExportedValue<IWindowManager>(new CustomWindowManager());
                    batch.AddExportedValue<Func<IMessageBox>>(() => Container.GetExportedValue<IMessageBox>());
                    batch.AddExportedValue<Func<HearthStatsDbContext>>(() => new HearthStatsDbContext());

                    // batch.AddExportedValue<IWindowManager>(new AppWindowManager());
                    // batch.AddExportedValue(MessageBus.Current);

                    var compose = Container.GetExportedValue<CompositionBuilder>();
                    compose.Compose(batch);
                    // var composeTasks = this.GetAllInstances<ICompositionTask>();
                    // composeTasks.Apply(s => s.Compose(batch));
                    Container.Compose(batch);
                });

            var initDbTask = Task.Factory.StartNew(InitializeDatabase);

            Task.WaitAll(composeTask, initDbTask);

            var logPath = Path.Combine((string)AppDomain.CurrentDomain.GetData("DataDirectory"), "logs");
            _logManager = Container.GetExportedValue<IAppLogManager>();
            _logManager.Initialize(logPath);
            Container.GetExportedValue<CrashManager>().WireUp();

            // Apply xaml/wpf fixes
            var currentUICult = Thread.CurrentThread.CurrentUICulture.Name;
            var currentCult = Thread.CurrentThread.CurrentCulture.Name;

            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(currentUICult);
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(currentCult);

            FrameworkElement.LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            // Hook caliburn filter
            FilterFrameworkCoreCustomization.Hook();

            // Hook application events
            Application.Activated += (s, e) => Container.GetExportedValue<IEventAggregator>().PublishOnCurrentThread(new ApplicationActivatedEvent());
            Application.Deactivated += (s, e) => Container.GetExportedValue<IEventAggregator>().PublishOnCurrentThread(new ApplicationDeActivatedEvent());
        }
开发者ID:ProjectTako,项目名称:HearthstoneTracker,代码行数:53,代码来源:AppBootstrapper.cs

示例14: RegisterInstancesAndResolveByName

        public void RegisterInstancesAndResolveByName()
        {
            using (CompositionContainer mefContainer = new CompositionContainer())
            {
                mefContainer.ComposeExportedValue<IService>("add", new ServiceAdd());
                mefContainer.ComposeExportedValue<IService>("sub", new ServiceSub());

                IService serviceAdd = mefContainer.GetExportedValue<IService>("add");
                IService serviceSub = mefContainer.GetExportedValue<IService>("sub");
                Assert.That(serviceAdd.Calc(1, 2), Is.EqualTo(3));
                Assert.That(serviceSub.Calc(5, 2), Is.EqualTo(3));
            }
        }
开发者ID:constructor-igor,项目名称:TechSugar,代码行数:13,代码来源:MEFSamples.cs

示例15: StateIsNotShared

        public void StateIsNotShared()
        {
            var container =
                new CompositionContainer(
                    new AggregateCatalog(
                        new AssemblyCatalog(typeof(ICurrentState<>).Assembly),
                        new TypeCatalog(typeof(TestCurrentState), typeof(TestState))));

            var state = container.GetExportedValue<IState<string>>();

            Assert.IsInstanceOfType(state, typeof(TestState));
            Assert.AreNotSame(state, container.GetExportedValue<IState<string>>());
        }
开发者ID:eslahi,项目名称:prism,代码行数:13,代码来源:StateManagementFixture.cs


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