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


C# CompositionBatch.AddPart方法代码示例

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


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

示例1: SatisfyImportsOnce

        public void SatisfyImportsOnce(ComposablePart part)
        {
            if (this.DoNothingOnSatisfyImportsOnce)
            {
                return;
            }

            CompositionBatch batch = new CompositionBatch();

            // We only want to include the standard exports and parts to compose in the first composition
            if (!this.alreadyComposed)
            {
                foreach (object instance in this.PartsToCompose)
                {
                    batch.AddPart(instance);
                }

                foreach (Export export in this.ExportsToCompose)
                {
                    batch.AddExport(export);
                }
            }

            if (part != null)
            {
                batch.AddPart(part);
            }

            this.container.Compose(batch);
            this.alreadyComposed = true;
        }
开发者ID:SonarSource-VisualStudio,项目名称:sonarlint-visualstudio,代码行数:31,代码来源:ConfigurableCompositionService.cs

示例2: Compose

        public void Compose(BaseParameters parameters)
        {
            try
            {
                var catalog = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly()),
                                                   new AssemblyCatalog(typeof(Logic.SanityCheck).Assembly));

                LoadPlugins(catalog, parameters);

                var container = new CompositionContainer(catalog);

                var batch = new CompositionBatch();
                batch.AddPart(this);
                batch.AddPart(parameters);

                var config = new Configuration(parameters.FileSystem, parameters.Path);
                config.ReadFromFile();
                batch.AddExportedValue((IConfiguration)config);

                container.Compose(batch);
            }
            catch (ReflectionTypeLoadException ex)
            {
                Console.WriteLine(@"Unable to load: \r\n{0}",
                    string.Join("\r\n", ex.LoaderExceptions.Select(e => e.Message)));

                throw;
            }
        }
开发者ID:Code52,项目名称:pretzel,代码行数:29,代码来源:Program.cs

示例3: ComposeBatchTwo

        private static void ComposeBatchTwo(CompositionContainer container)
        {
            var batch = new CompositionBatch();
            batch.RemovePart(a);
            c = batch.AddPart(new PluginC());
            batch.AddPart(logger);

            container.Compose(batch);
        }
开发者ID:mikeminutillo,项目名称:mef-sandbox,代码行数:9,代码来源:Program.cs

示例4: Main

        static void Main() 
        {
            // important to call these before creating application host
            Application.EnableVisualStyles();
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // Create a catalog with all the components that make up the application, except for
            //  our MainForm.
            var catalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(HelpAboutCommand),               // Help -> About command
                typeof(FolderViewer),                   // manages TreeControl to display folder hierarchy
                typeof(FileViewer),                     // managed ListView to display last selected folder contents

                typeof(NameDataExtension),              // extension to display file name
                typeof(SizeDataExtension),              // extension to display file size
                typeof(CreationTimeDataExtension),      // extension to display file creation time

                typeof(UserFeedbackService),            // component to send feedback form to SHIP
                typeof(VersionUpdateService),           // component to update to latest version on SHIP

                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService)               // provides facilities to run an automated script using the .NET remoting service
                );          

            var container = new CompositionContainer(catalog);

            // manually add the MainForm
            var batch = new CompositionBatch();
            var mainForm = new MainForm
            {
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };
            // our custom main Form with SplitContainer
            batch.AddPart(mainForm);
            batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-File-Explorer-Sample".Localize()));
            container.Compose(batch);

            // initialize all components which require it
            container.InitializeAll();
            
            Application.Run(mainForm);

            container.Dispose();
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:57,代码来源:Program.cs

示例5: ComposeBatchOne

        private static void ComposeBatchOne(CompositionContainer container)
        {
            var batch = new CompositionBatch();

            a = batch.AddPart(new PluginA());
            b = batch.AddPart(new PluginB());

            batch.AddPart(bootstrapper);

            container.Compose(batch);
        }
开发者ID:mikeminutillo,项目名称:mef-sandbox,代码行数:11,代码来源:Program.cs

示例6: FunctionsFieldsAndProperties2

        public void FunctionsFieldsAndProperties2()
        {
            Consumer c;
            var container = ContainerFactory.Create();

            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(new SubtractProvider());
            batch.AddPart(c = new Consumer());
            container.Compose(batch);

            Assert.AreEqual(-1, c.op(c.a, c.b), "1 - 2 == -1");
        }
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:AdvancedValueComposition.cs

示例7: App

        public App()
        {
            var catalog = new AggregateCatalog(new DirectoryCatalog(Path.GetDirectoryName(typeof(App).Assembly.Location)), new AssemblyCatalog(typeof(App).Assembly));

            _container = new CompositionContainer(catalog);

            var batch = new CompositionBatch();
            batch.AddPart(ExistingComposablePart.Create<ExportProvider>(_container));
            batch.AddPart(ExistingComposablePart.Create(_container));

            _container.Compose(batch);
        }
开发者ID:hugodahl,项目名称:powershell-for-developers,代码行数:12,代码来源:App.xaml.cs

示例8: PrivateFromPublic

        public void PrivateFromPublic()
        {
            var container = ContainerFactory.Create();
            CompositionBatch batch = new CompositionBatch();
            var importer = new AllPrivateImportOnly();
            batch.AddPart(importer);
            batch.AddPart(new AllPublicExportOnly() { ExportA = 5, ExportB = 10 });
            container.Compose(batch);

            Assert.AreEqual(5, importer.PublicImportA);
            Assert.AreEqual(10, importer.PublicImportB);
        }
开发者ID:JackFong,项目名称:FreeRadical,代码行数:12,代码来源:AllowNonPublicCompositionTests.cs

示例9: ImportSingleToInternal

        public void ImportSingleToInternal()
        {
            var container = ContainerFactory.Create();
            var importer = new Int32ImporterInternal();
            var exporter = new Int32Exporter(42);

            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(importer);
            batch.AddPart(exporter);
            container.Compose(batch);

            Assert.AreEqual(42, importer.Value, "Expecting value to be imported");
        }
开发者ID:JackFong,项目名称:FreeRadical,代码行数:13,代码来源:CompositionContainerImportTests.cs

示例10: ConstructorInjectionCycle

        public void ConstructorInjectionCycle()
        {
            var container = ContainerFactory.Create();
            CompositionBatch batch = new CompositionBatch();

            batch.AddPart(new ConstructorInjectionComposablePart(typeof(AClass)));
            batch.AddPart(new ConstructorInjectionComposablePart(typeof(BClass)));

            CompositionAssert.ThrowsErrors(ErrorId.ImportEngine_PartCannotSetImport,
                                           ErrorId.ImportEngine_PartCannotSetImport, RetryMode.DoNotRetry, () =>
            {
                container.Compose(batch);
            });
        }
开发者ID:whereisaaron,项目名称:mono,代码行数:14,代码来源:ComposablePartExtensibilityTests.cs

示例11: ImportTest

        public void ImportTest()
        {
            var exporter = new TestExportBinder();
            var importer = new TestImportBinder();

            CompositionContainer container = ContainerFactory.Create();
            CompositionBatch batch = new CompositionBatch();

            batch.AddPart(importer);
            batch.AddPart(exporter);
            container.Compose(batch);

            ExportsAssert.AreEqual(importer.SetImports["single"], 42);
            ExportsAssert.AreEqual(importer.SetImports["multi"], 1, 2, 3);
        }
开发者ID:whereisaaron,项目名称:mono,代码行数:15,代码来源:ComposablePartExtensibilityTests.cs

示例12: Compose

        public void Compose()
        {
            AssemblyCatalog assemblyCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());

            string executionPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            string generatorsPath = Path.Combine(executionPath, "Generators");
            CreatePathIfRequied(generatorsPath);
            generatorsCatalog = new DirectoryCatalog(generatorsPath);

            string uiPath = Path.Combine(executionPath, "UI");
            CreatePathIfRequied(uiPath);
            UICatalog = new DirectoryCatalog(uiPath);

            AggregateCatalog catalog = new AggregateCatalog();
            catalog.Catalogs.Add(generatorsCatalog);
            catalog.Catalogs.Add(UICatalog);

            //Set the defaults....
            CatalogExportProvider mainProvider = new CatalogExportProvider(assemblyCatalog);
            CompositionContainer container = new CompositionContainer(catalog, mainProvider);
            mainProvider.SourceProvider = container;

            var batch = new CompositionBatch();
            batch.AddPart(this);

            RefreshCatalog refreshCatalog = new RefreshCatalog(generatorsCatalog, UICatalog);
            container.ComposeParts(refreshCatalog);
            container.Compose(batch);

            Logger.Write("Compose complete");
        }
开发者ID:BenHall,项目名称:ExtendViaMEF,代码行数:32,代码来源:Extender.cs

示例13: MainForm

        /// <summary>
        /// Initialises a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            this.InitializeComponent();

            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new DirectoryCatalog("..\\..\\Crypto", "*.dll"));
            var batch = new CompositionBatch();
            batch.AddPart(this);
            this.compositionContainer = new CompositionContainer(catalog);
            ////get all the exports and load them into the appropriate list tagged with the importmany
            this.compositionContainer.Compose(batch);

            this.CryptoAlgorithmComboBox.DataSource = (new List<CryptoAlgorithm> { CryptoAlgorithm.None }).Union(
                this.CryptoProviders.Select(c => c.Metadata.Algorithm).Distinct()).ToList();

            this.JoinedUsers = new BindingList<User>();

            this.ConnectedUsersDataGridView.DataSource = this.JoinedUsers;
            this.userProxy = new UserServiceClient(new InstanceContext(this));

            this.userProxy.Open();
            this.messagingProxy = new MessagingServiceClient(new InstanceContext(this));
            this.messagingProxy.Open();

            this.userProxy.Subscribe();
            foreach (var u in this.userProxy.GetJoinedUsers())
            {
                this.AddUser(u);
            }

            this.uiSyncContext = SynchronizationContext.Current;
        }
开发者ID:famstutz,项目名称:YAEM,代码行数:35,代码来源:MainForm.cs

示例14: Compose

 private void Compose()
 {
     var container = new CompositionContainer(directories);
       var batch = new CompositionBatch();
       batch.AddPart(this);
       container.Compose(batch);
 }
开发者ID:edgar-pek,项目名称:VCDryad,代码行数:7,代码来源:PluginManager.cs

示例15: FunctionsFieldsAndProperties2_WithCatalog

        public void FunctionsFieldsAndProperties2_WithCatalog()
        {
            var container = ContainerFactory.CreateWithDefaultAttributedCatalog();

            ConsumerOfMultiple c = new ConsumerOfMultiple();
            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(c);
            container.Compose(batch);

            foreach (var export in c.opInfo)
            {
                if ((string)export.Metadata["Var1"] == "add")
                {
                    Assert.AreEqual(3, export.Value(1, 2), "1 + 2 == 3");
                }
                else if ((string)export.Metadata["Var1"] == "sub")
                {
                    Assert.AreEqual(-1, export.Value(1, 2), "1 - 2 == -1");
                }
                else
                {
                    Assert.Fail("Unexpected value");
                }
            }
        }
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:AdvancedValueComposition.cs


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