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


C# Hosting.CompositionContainer类代码示例

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


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

示例1: ExtensionManager

        /// <summary>
        /// Default private constructor.
        /// </summary>
        private ExtensionManager()
        {
            if (!Config.DisableComposition)
            {
                // Let MEF scan for imports
                var catalog = new AggregateCatalog();

                catalog.Catalogs.Add(Config.DisableCatalogSearch ? new DirectoryCatalog("Bin", "Piranha*.dll") : new DirectoryCatalog("Bin"));

            #if !NET40
                if (!System.Web.Compilation.BuildManager.IsPrecompiledApp)
                {
            #endif
                    try
                    {
                        // This feature only exists for Web Pages
                        catalog.Catalogs.Add(new AssemblyCatalog(Assembly.Load("App_Code")));
                    }
                    catch { }
            #if !NET40
                }
            #endif

                Container = new CompositionContainer(catalog);
                Container.ComposeParts(this);
            }
        }
开发者ID:cnascimento,项目名称:Paladino,代码行数:30,代码来源:ExtensionManager.cs

示例2: AssembleComponents

        /// <summary>
        /// This method loads the plugins.
        /// </summary>
        private void AssembleComponents()
        {
            var catalog = new AggregateCatalog();

            //Note: we load not only from the plugins folder, but from this assembly as well.
            var executingAssemblyCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());

            if (Directory.Exists(Environment.CurrentDirectory + "\\Plugins"))
            {
                catalog.Catalogs.Add(new DirectoryCatalog("Plugins"));
            }

            catalog.Catalogs.Add(executingAssemblyCatalog);

            var container = new CompositionContainer(catalog);

            try
            {
                container.ComposeParts(this);
            }
            catch (CompositionException compositionException)
            {
                _dialogService.ShowMessageAsync(_mainVm, "Error", string.Format("There was an error loading plugins: {0}", compositionException)).Forget();
            }
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:28,代码来源:StatementHandler.cs

示例3: LoadPlugins

        public void LoadPlugins(IEnumerable<ComposablePartCatalog> catalogs = null)
        {
            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new AssemblyCatalog(GetType().Assembly));

            if (catalogs != null)
            {
                foreach (var additionalCatalog in catalogs)
                {
                    catalog.Catalogs.Add(additionalCatalog);
                }
            }

            //Create the CompositionContainer with the parts in the catalog
            Container = new CompositionContainer(catalog);

            //Fill the imports of this object
            try
            {
                Container.ComposeParts(this);
            }
            catch (CompositionException compositionException)
            {
                Console.WriteLine(compositionException.ToString());
            }
        }
开发者ID:EdwardSalter,项目名称:NCubeSolver,代码行数:26,代码来源:PluginLoader.cs

示例4: FilterContext

 public FilterContext(ObjectCache cache, CompositionContainer container, IAssetResolver assetResolver, FilterState state)
 {
     this.Container = container;
     this.Cache = cache;
     this.AssetResolver = assetResolver;
     this.State = state;
 }
开发者ID:ppittle,项目名称:LBi.LostDoc,代码行数:7,代码来源:FilterContext.cs

示例5: Invoke

        public override void Invoke(CompositionContainer container)
        {
            TemplateInfo templateInfo;
            if (!this.TemplateResolver.TryResolve(this.Template, out templateInfo))
                Console.WriteLine("Template not found: '{0}'.", this.Template);

            do
            {
                foreach (string filename in templateInfo.GetFiles())
                {
                    Console.WriteLine(filename);
                    string targetPath = System.IO.Path.Combine(this.Path, filename);
                    string targetDir = System.IO.Path.GetDirectoryName(targetPath);
                    Directory.CreateDirectory(targetDir);
                    using (var target = new FileStream(targetPath, FileMode.CreateNew, FileAccess.Write, FileShare.None))
                    using (var content = templateInfo.Source.OpenFile(filename, FileMode.Open))
                    {
                        content.CopyTo(target);
                        content.Close();
                        target.Close();
                    }
                }

                templateInfo = templateInfo.Inherits;
            } while (this.IncludeInherited && templateInfo != null);
        }
开发者ID:LBiNetherlands,项目名称:LBi.LostDoc,代码行数:26,代码来源:SaveTemplateCommand.cs

示例6: DualContainers

        public void DualContainers()
        {
            var container1 = new CompositionContainer();
            TypeDescriptorServices dat1 = new TypeDescriptorServices();
            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(dat1);
            container1.Compose(batch);
            MetadataStore.AddAttribute(
                typeof(DynamicMetadataTestClass),
                ( type, attributes) => 
                    Enumerable.Concat(
                        attributes,
                        new Attribute[] { new TypeConverterAttribute(typeof(DynamicMetadataTestClassConverter)) }
                    ),
                container1
            );


            var container2 = new CompositionContainer();
            CompositionBatch batch2 = new CompositionBatch();
            TypeDescriptorServices dat2 = new TypeDescriptorServices();
            batch2.AddPart(dat2);
            container2.Compose(batch2);

            DynamicMetadataTestClass val = DynamicMetadataTestClass.Get("42");

            var attached1 = dat1.GetConverter(val.GetType());
            Assert.IsTrue(attached1.CanConvertFrom(typeof(string)), "The new type converter for DynamicMetadataTestClass should support round tripping");

            var attached2 = dat2.GetConverter(val.GetType());
            Assert.IsFalse(attached2.CanConvertFrom(typeof(string)), "The default type converter for DynamicMetadataTestClass shouldn't support round tripping");
        }
开发者ID:nlhepler,项目名称:mono,代码行数:32,代码来源:DynamicMetadata.cs

示例7: AsyncMain

    static async Task AsyncMain()
    {
        AggregateCatalog catalog = new AggregateCatalog();
        catalog.Catalogs.Add(new DirectoryCatalog("."));

        CompositionContainer compositionContainer = new CompositionContainer(catalog);

        Console.Title = "Samples.MefExtensionEndpoint";
        LogManager.Use<DefaultFactory>().Level(LogLevel.Info);
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.MefExtensionEndpoint");
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.EnableInstallers();
        await RunCustomizeConfiguration(compositionContainer, endpointConfiguration);
        await RunBeforeEndpointStart(compositionContainer);
        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        await RunAfterEndpointStart(compositionContainer, endpoint);
        try
        {
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await RunBeforeEndpointStop(compositionContainer, endpoint);
            await endpoint.Stop();
        }
        await RunAfterEndpointStop(compositionContainer);
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:28,代码来源:Program.cs

示例8: TestMefStatusReportable

        public void TestMefStatusReportable()
        {
            string dir = AssemblyDirectory;

            //Lets get the nlog status reportable from MEF directory..
            CompositionContainer _container;
            //An aggregate catalog that combines multiple catalogs
            var catalog = new AggregateCatalog();
            //Adds all the parts found in the same assembly as the Program class
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(TestMEF).Assembly));
            catalog.Catalogs.Add(new DirectoryCatalog(AssemblyDirectory));

            //Create the CompositionContainer with the parts in the catalog
            _container = new CompositionContainer(catalog);

            //Fill the imports of this object
            try
            {
               _container.ComposeParts(this);
            }
            catch (CompositionException compositionException)
            {
                Console.WriteLine(compositionException.ToString());
            }

            reporter.Report(2,1,"Test Report");
        }
开发者ID:framirezh,项目名称:encog-dotnet-core,代码行数:27,代码来源:TestMEF.cs

示例9: Initialize

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

            //Adds the program's assembly
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(PluginInfrastructre).Assembly));


            string programassembly = System.Reflection.Assembly.GetAssembly(typeof(PluginInfrastructre)).Location;

            string programpath = Path.GetDirectoryName(programassembly);

            //add the program's path
            catalog.Catalogs.Add(new DirectoryCatalog(programpath));

            _container = new CompositionContainer(catalog);

            try
            {
                //Initialize types found and assign new instances to Plugins
                Plugins = _container.GetExportedValues<IPlugin>();
                
            }
            catch (CompositionException compositionException)
            {
                throw;
            }
        }
开发者ID:kiszu,项目名称:ForBlog,代码行数:28,代码来源:PluginInfrastructre.cs

示例10: Configure

        /// <summary>
        /// MEF Bootstrap (MEF comes from System.ComponentModel.Composition in the GAC).
        /// <para>This will return a class containing all the application's aggregate roots.</para>
        /// </summary>
        public static ComposedDemoProgram Configure(params string[] pluginDirectories)
        {
            var catalogues = 
                pluginDirectories.Select<string, ComposablePartCatalog>(d=>new DirectoryCatalog(d)).
                Concat(new []{new AssemblyCatalog(Assembly.GetExecutingAssembly())}).ToList();

            var catalog = new AggregateCatalog(catalogues);
            try
            {
                var container = new CompositionContainer(catalog);

                var composedProgram = new ComposedDemoProgram();
                container.SatisfyImportsOnce(composedProgram);

                return composedProgram;
            }
            finally
            {
                catalog.Dispose();
                foreach (var cat in catalogues)
                {
                    cat.Dispose();
                }
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:29,代码来源:Program.cs

示例11: ProcessResultOperator

        /// <summary>
        /// Actually try and process this! The count consisits of a count integer and something to increment it
        /// at its current spot.
        /// </summary>
        /// <param name="resultOperator"></param>
        /// <param name="queryModel"></param>
        /// <param name="codeEnv"></param>
        /// <returns></returns>
        public Expression ProcessResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, IGeneratedQueryCode gc, ICodeContext cc, CompositionContainer container)
        {
            if (gc == null)
                throw new ArgumentNullException("CodeEnv must not be null!");

            var c = resultOperator as CountResultOperator;
            if (c == null)
                throw new ArgumentNullException("resultOperator can only be a CountResultOperator and must not be null");

            //
            // The accumulator where we will store the result.
            //

            var accumulator = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            accumulator.SetInitialValue("0");

            //
            // Use the Aggregate infrasturcutre to do the adding. This
            // has the advantage that it will correctly combine with
            // similar statements during query optimization.
            //

            var add = Expression.Add(accumulator, Expression.Constant((int)1));
            var addResolved = ExpressionToCPP.GetExpression(add, gc, cc, container);

            gc.Add(new StatementAggregate(accumulator, addResolved));
            return accumulator;
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:36,代码来源:ROCount.cs

示例12: Initialize

        public void Initialize()
        {
            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(NotifiedElementPoster)),
                    new TypeCatalog(typeof (UnnotifiedElementGetter)),
                    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);
            //_poster = _mockRepository.DynamicMock<NotifiedElementPoster>();
            //_posterFactory = _mockRepository.DynamicMock<IPacketResourcePoster>();
        //    container.ComposeExportedValue<ResourcePoster>(_poster);
            container.ComposeExportedValue(_posterFactory);
            _pool = container.GetExportedValue<ITypedPool>();
            _subscriptor = container.GetExportedValue<IAnnouncerSubscriptor>();
            var service = container.GetExportedValue<ICacheServicing>();
            service.Initialize(new Settings
            {
                
            }, container);
        }
开发者ID:kayanme,项目名称:Dataspace,代码行数:34,代码来源:TransactionNotificationFeatureTest.cs

示例13: FileController

        public FileController(CompositionContainer container, IMessageService messageService, IFileDialogService fileDialogService,
            IShellService shellService, FileService fileService)
        {
            this.container = container;
            this.messageService = messageService;
            this.fileDialogService = fileDialogService;
            this.shellService = shellService;
            this.fileService = fileService;
            this.documentTypes = new List<IDocumentType>();

            this.newDocumentCommand = new DelegateCommand(NewDocumentCommand, CanNewDocumentCommand);
            this.closeDocumentCommand = new DelegateCommand(CloseDocumentCommand, CanCloseDocumentCommand);
            this.saveDocumentCommand = new DelegateCommand(SaveDocumentCommand, CanSaveDocumentCommand);
            this.saveAllDocumentCommand = new DelegateCommand(SaveAllDocumentCommand, CanSaveAllDocumentCommand);
            this.newSolutionCommand = new DelegateCommand(NewSolutionCommand);
            this.openSolutionCommand = new DelegateCommand(OpenSolutionCommand);
            this.closeSolutionCommand = new DelegateCommand(CloseSolutionCommand, CanCloseSolutionCommand);
            this.showSolutionCommand = new DelegateCommand(ShowSolutionCommand, CanShowSolutionCommand);

            this.fileService.NewDocumentCommand = this.newDocumentCommand;
            this.fileService.CloseDocumentCommand = this.closeDocumentCommand;
            this.fileService.SaveDocumentCommand = this.saveDocumentCommand;
            this.fileService.SaveAllDocumentCommand = this.saveAllDocumentCommand;
            this.fileService.NewSolutionCommand = this.newSolutionCommand;
            this.fileService.OpenSolutionCommand = this.openSolutionCommand;
            this.fileService.CloseSolutionCommand = this.closeSolutionCommand;
            this.fileService.ShowSolutionCommand = this.showSolutionCommand;

            this.recentSolutionList = Settings.Default.RecentSolutionList;
            if (this.recentSolutionList == null) { this.recentSolutionList = new RecentFileList(); }
            this.fileService.RecentSolutionList = recentSolutionList;

            AddWeakEventListener(fileService, FileServicePropertyChanged);
        }
开发者ID:naindejardin,项目名称:Financial-Management-Studio,代码行数:34,代码来源:FileController.cs

示例14: CreateRun

        private static IRun CreateRun()
        {
            ThreadPool.SetMinThreads(32, 32);

            var args = ParseArguments();

            var compositionContainer = new CompositionContainer(new AssemblyCatalog(typeof(Program).Assembly));

            compositionContainer.ComposeExportedValue(new RunData
            {
                SampleRate = args.SampleRate,
                Warmup = args.Warmup,
                Duration = args.Duration,
                Connections = args.Connections,
                Payload = GetPayload(args.PayloadSize),
                Senders = args.Senders,
                Transport = args.Transport,
                Host = args.Host,
                Url = args.Url,
                SendDelay = args.SendDelay,

                // Scaleout
                RedisServer = args.RedisServer,
                RedisPort = args.RedisPort,
                RedisPassword = args.RedisPassword,
                ServiceBusConnectionString = args.ServiceBusConnectionString,
                SqlConnectionString = args.SqlConnectionString,
                SqlTableCount = args.SqlTableCount,
            });

            return compositionContainer.GetExportedValue<IRun>(args.RunName);
        }
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:32,代码来源:Program.cs

示例15: DoImport

        public void DoImport()
        {
            //An aggregate catalog that combines multiple catalogs
            var catalog = new AggregateCatalog();

            directoryCatalog = new DirectoryCatalog(GetDirectory());
            directoryCatalog.Changing += directoryCatalog_Changing;
            directoryCatalog.Changed += directoryCatalog_Changed;

            //Adds all the parts found in all assemblies in 
            //the same directory as the executing program
            catalog.Catalogs.Add(directoryCatalog);

            //Create the CompositionContainer with the parts in the catalog
            var container = new CompositionContainer(catalog);

            try
            {
                //Fill the imports of this object
                container.ComposeParts(this);
            }
            catch (Exception ex)
            {
                Out.WriteLine("Unable to load plugins: {0}", ex.Message);
            }

        }
开发者ID:Olezhka,项目名称:Hipbot,代码行数:27,代码来源:Program.cs


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