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


C# CompositionBatch.AddExportedValue方法代码示例

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


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

示例1: BindServices

	    protected virtual void BindServices(CompositionBatch batch)
        {
            batch.AddExportedValue<IWindowManager>(new WindowManager());
            batch.AddExportedValue<IEventAggregator>(new EventAggregator());
            batch.AddExportedValue(Container);
	        batch.AddExportedValue(this);
        }
开发者ID:DraTeots,项目名称:gemini,代码行数:7,代码来源:AppBootstrapper.cs

示例2: Compose

        private bool Compose()
        {
            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(IMefShapesGame).Assembly));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(DefaultDimensions).Assembly));
            var partCreatorEP = new DynamicInstantiationExportProvider();

            this._container = new CompositionContainer(catalog, partCreatorEP);
            partCreatorEP.SourceProvider = this._container;

            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(this);
            batch.AddExportedValue<ICompositionService>(this._container);
            batch.AddExportedValue<AggregateCatalog>(catalog);

            try
            {
                this._container.Compose(batch);
            }
            catch (CompositionException compositionException)
            {
                MessageBox.Show(compositionException.ToString());
                Shutdown(1);
                return false;
            }
            return true;
        }
开发者ID:JackFong,项目名称:FreeRadical,代码行数:27,代码来源:App.cs

示例3: Configure

        protected override void Configure()
        {
            _container = new CompositionContainer(
                new AggregateCatalog(
                    AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>()
                    )
                );

            MessageBinder.SpecialValues.Add("$orignalsourcecontext", context =>
            {
                var args = context.EventArgs as RoutedEventArgs;
                if (args == null)
                {
                    return null;
                }

                var fe = args.OriginalSource as FrameworkElement;
                if (fe == null)
                {
                    return null;
                }

                return fe.DataContext;
            });

            var batch = new CompositionBatch();

            batch.AddExportedValue<IWindowManager>(new WindowManager());
            batch.AddExportedValue<IEventAggregator>(new EventAggregator());
            batch.AddExportedValue(_container);

            _container.Compose(batch);
        }
开发者ID:narukunegu,项目名称:ESClinic,代码行数:33,代码来源:AppBootstrapper.cs

示例4: Configure

        /// <summary>Override to configure the framework and setup your IoC container.</summary>
        protected override void Configure()
        {
            // Add the assembly source to the catalog.
            // ReSharper disable once RedundantEnumerableCastCall
            var catalog = new AggregateCatalog(AssemblySource.Instance.Select(i => new AssemblyCatalog(i)).OfType<ComposablePartCatalog>());

            // Create a new composition container.
            // ReSharper disable once RedundantEnumerableCastCall
            this.container = new CompositionContainer();

            // Create a new composition container.
            this.container = new CompositionContainer(catalog);

            CompositionBatch compositionBatch = new CompositionBatch();

            // Add EventAggregator to composition batch.
            compositionBatch.AddExportedValue<IEventAggregator>(new EventAggregator());
            compositionBatch.AddExportedValue<IWindowManager>(new WindowManager());
            compositionBatch.AddExportedValue<ISettingsRepository>(new SettingsRepository());
            compositionBatch.AddExportedValue<ISolutionRepository>(new SolutionRepository());
            compositionBatch.AddExportedValue(new LogWriter(this.BuildLoggingConfiguration()));

            // Add the container itself.
            compositionBatch.AddExportedValue(this.container);

            // Compose the container.
            this.container.Compose(compositionBatch);
        }
开发者ID:Ruhrpottpatriot,项目名称:SkyrimCompileHelper,代码行数:29,代码来源:MefBootstrapper.cs

示例5: GetServiceLocator

        internal static IServiceLocator GetServiceLocator(Assembly assembly, CompositionBatch batch)
        {
            var assemblyLocation = assembly.Location;
            var file = new FileInfo(assemblyLocation);

            var catalogs = new List<ComposablePartCatalog>
            {
                new AssemblyCatalog(assembly),
                new DirectoryCatalog(file.DirectoryName ?? ".")
            };

            var catalog = new AggregateCatalog(catalogs);

            var container = new CompositionContainer(catalog,
                                                        CompositionOptions.DisableSilentRejection |
                                                        CompositionOptions.IsThreadSafe );

            var serviceLocator = new MefServiceLocator(container);

            batch.AddExportedValue(container);
            batch.AddExportedValue<IServiceLocator>(serviceLocator);

            container.Compose(batch);

            return serviceLocator;
        }
开发者ID:Hem,项目名称:SimpleNet,代码行数:26,代码来源:MefRegistration.cs

示例6: SingleContainerPartReplacement

        public void SingleContainerPartReplacement()
        {
            var container = ContainerFactory.Create();
            var importPart = PartFactory.CreateImporter(true, "value1", "value2");

            CompositionBatch batch = new CompositionBatch();
            var export1Key = batch.AddExportedValue("value1", "Hello");
            batch.AddExportedValue("value2", "World");
            batch.AddPart(importPart);
            container.Compose(batch);

            Assert.AreEqual(2, importPart.ImportSatisfiedCount);
            Assert.AreEqual("Hello", importPart.GetImport("value1"));
            Assert.AreEqual("World", importPart.GetImport("value2"));

            importPart.ResetImportSatisfiedCount();

            batch = new CompositionBatch();
            batch.RemovePart(export1Key);
            batch.AddExportedValue("value1", "Goodbye");
            container.Compose(batch);

            Assert.AreEqual(1, importPart.ImportSatisfiedCount);
            Assert.AreEqual("Goodbye", importPart.GetImport("value1"));
            Assert.AreEqual("World", importPart.GetImport("value2"));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:26,代码来源:InitializationScopeTests.cs

示例7: Init

        public Runner Init(IFeedbackProvider feedbackProvider, string[] args)
        {
            var catalog = new AggregateCatalog(new AssemblyCatalog(typeof(Bootstrapper).Assembly));

            var currentDir = Environment.CurrentDirectory;
            var assemblyDir = new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath).Directory.FullName;

            var paths = new string[]
            {
                assemblyDir,
                Path.Combine(assemblyDir, "Tasks"),
                currentDir,
                Path.Combine(currentDir, "Tasks")
            }.Unique();

            var dirCatalogs = paths.Where(x => Directory.Exists(x))
                                   .Select(x => new DirectoryCatalog(x, "*.Tasks.dll"));
            dirCatalogs.Apply(x => catalog.Catalogs.Add(x));

            var container = new CompositionContainer(catalog);

            var parsed = new ArgumentParser().Parse(args);
            var runner = new Runner(parsed.ActualArgs.ToArray());

            var batch = new CompositionBatch();
            batch.AddExportedValue<IFeedbackProvider>(feedbackProvider);
            parsed.Options.Apply(x => batch.AddExportedValue<string>(x.Item1, x.Item2));
            parsed.Switches.Apply(x => batch.AddExportedValue<bool>(x, true));
            batch.AddPart(runner);
            container.Compose(batch);

            return runner;
        }
开发者ID:mikeminutillo,项目名称:task,代码行数:33,代码来源:Bootstrapper.cs

示例8: Configure

		protected override void Configure()
		{
			_container = new CompositionContainer(new AggregateCatalog(AssemblySource
					.Instance
					.Select(x => new AssemblyCatalog(x))
					.OfType<ComposablePartCatalog>()
				)
			);

			var batch = new CompositionBatch();
			
			_portName = SerialPort.GetPortNames()[0];
			_ecr = new Dp25(_portName);

			var messenger = new MessageAggregator();

			messenger.GetStream<SelectedPortChangedEvent>()
					.Subscribe(e => _ecr.ChangePort(e.PortName));



			batch.AddExportedValue<IWindowManager>(new WindowManager());
			batch.AddExportedValue<IMessageAggregator>(messenger);
			batch.AddExportedValue<Dp25>(_ecr);
			batch.AddExportedValue(_container);

			_container.Compose(batch);
		}
开发者ID:BurnOutDev,项目名称:Kasa.ge,代码行数:28,代码来源:AppBootstrapper.cs

示例9: Configure

        protected override void Configure()
        {
            _container = new CompositionContainer(
                new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)))
                );

            var batch = new CompositionBatch();

            var fileStream = new FileStream(LocalSettings.ClientXmlFilePath, FileMode.OpenOrCreate, FileAccess.Read);
            _settings = SettingsManager.LoadSettings<LocalSettings>(fileStream);

            if (_settings == null)
            {
                _settings = new LocalSettings { FirstRun = true };
            }
            else
            {
                _settings.FirstRun = false;
            }

            batch.AddExportedValue(_settings);
            batch.AddExportedValue<IWindowManager>(new WindowManager());
            batch.AddExportedValue<IEventAggregator>(new EventAggregator());
            batch.AddExportedValue(_container);

            _container.Compose(batch);
        }
开发者ID:fcin,项目名称:RemindMe,代码行数:27,代码来源:Bootstrapper.cs

示例10: BatchMultipleAdds_ShouldFireEvents

        public void BatchMultipleAdds_ShouldFireEvents()
        {
            var container = ContainerFactory.Create();
            var eventListener = new ExportProviderListener(container, container);

            var batch = new CompositionBatch();
            batch.AddExportedValue<object>("MyExport", new object());
            batch.AddExportedValue<object>("MyExport2", new object());
            batch.AddExportedValue<object>("MyExport3", new object());
            eventListener.VerifyCompose(batch);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:ExportProviderEventTests.cs

示例11: Compose

        public void Compose()
        {
            var first = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            var container = new CompositionContainer(first);

            var batch = new CompositionBatch();
            batch.AddExportedValue<IFileSystem>(new FileSystem());
            batch.AddExportedValue<IContentTransform>(new WebSequenceDiagrams());
            batch.AddPart(this);
            container.Compose(batch);
        }
开发者ID:AndreiMarukovich,项目名称:pretzel,代码行数:11,代码来源:Program.cs

示例12: Configure

        /* Managed Extensibility Framework
         * A lot of this is just copy paste code, from http://caliburnmicro.com/documentation/bootstrapper
         * This is used to make whatever we store in our CompositionContainer available across the application.
         * In this example we have put the windowmanager and the evenAggregator in it.
         * The WindowManager manages creation and showing of windows/dialogs/stuff like that.
         * The EventAggregator is a service that provides us with the ability to publish objects from one entity to another, in a loose fashion. http://caliburnmicro.com/documentation/event-aggregator
         * Once the configure part of this is setup, you can go to your respective classes, and mark them with the [Export] attribute, and then if you for example
         * wanted to get a local instance of the windowmanager, mark the constructor with the [ImportingConstructor], like this:
         *  [ImportingConstructor]
         *  public AppViewModel(IWindowManager windowManager)
         * which will make the framework put in the applications instance of the windowmanager, for use in whatever you want to.
         */
        protected override void Configure()
        {
            _container = new CompositionContainer(new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>()));

            //Collects values/stuff that has to go in our container
            CompositionBatch batch = new CompositionBatch();
            batch.AddExportedValue<IWindowManager>(new WindowManager());
            batch.AddExportedValue<IEventAggregator>(new EventAggregator());
            batch.AddExportedValue(_container);
            _container.Compose(batch);
        }
开发者ID:Lucrah,项目名称:P3,代码行数:23,代码来源:BootStrapper.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: Configure

        protected override void Configure()
        {
            var catalog = new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>());
            container = new CompositionContainer(catalog);

            var batch = new CompositionBatch();
            batch.AddExportedValue<IWindowManager>(new WindowManager());
            batch.AddExportedValue<IEventAggregator>(new EventAggregator());
            batch.AddExportedValue(container);

            container.Compose(batch);
        }
开发者ID:lycilph,项目名称:Projects,代码行数:12,代码来源:AppBootstrapper.cs

示例15: Configure

        protected override void Configure()
        {
            container = new CompositionContainer(new AssemblyCatalog(Assembly.GetAssembly(typeof(ShellViewModel))));

            var batch = new CompositionBatch();

            batch.AddExportedValue<IWindowManager>(new WindowManager());
            batch.AddExportedValue<IEventAggregator>(new EventAggregator());

            batch.AddExportedValue(container);
            container.Compose(batch);
        }
开发者ID:KleeUT,项目名称:MVVMTestingDemo,代码行数:12,代码来源:LocationRecorderBootStrapper.cs


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