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


C# CompositionContainer.GetExportedValues方法代码示例

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


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

示例1: Run

        public void Run()
        {
            PermissionPrincipal permissionsPrincipal = new PermissionPrincipal();
            AppDomain.CurrentDomain.SetThreadPrincipal(permissionsPrincipal);

            if (Assembly.GetCallingAssembly().GetName().Name != ServiceAssemblyName)
            {
                throw new Exception(Core.UI.Properties.Resources.ErrorMustBeLoadedFromService);
            }
            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new DirectoryCatalog(@"..\..\..\TixCRM.TestModule\bin\Debug"));
            catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetAssembly(typeof(MainWindow))));
            catalog.Catalogs.Add(new DirectoryCatalog(@"..\..\..\TixCRM.Core.Services\bin\Debug"));
            catalog.Catalogs.Add(new DirectoryCatalog(@"..\..\..\TixCRM.Core.Data\bin\Debug"));
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);

            foreach (var module in modules)
            {
                if (CheckModule(module))
                {
                    module.Init(menuServiceFactory.CreateMenuService(),
                        container.GetExportedValues<ITixViewModel>().Single(x => x.TixViewModelName == module.ViewModelName),
                        container.GetExportedValues<ITixView>().Single(x => x.TixViewName == module.ViewName), mRegistery);
                }
                else
                {
                    throw new ModuleLoadException(String.Format(Core.UI.Properties.Resources.ErrorCouldNotLoadModule, module.DisplayName));
                }

            }

            App.Start(container.GetExportedValue<ITixViewModel>("TixCRM.Core.UI.MainViewModel"));
        }
开发者ID:tofi92,项目名称:TixCRM,代码行数:34,代码来源:Main.cs

示例2: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            DispatcherUnhandledException += AppDispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;

            catalog = new AggregateCatalog();
            // Add the WpfApplicationFramework assembly to the catalog
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(IMessageService).Assembly));
            
            // Load module assemblies as well. See App.config file.
            foreach (string moduleAssembly in Settings.Default.ModuleAssemblies)
            {
                catalog.Catalogs.Add(new AssemblyCatalog(moduleAssembly));
            }

            container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection);
            CompositionBatch batch = new CompositionBatch();
            batch.AddExportedValue(container);
            container.Compose(batch);

            // Initialize all presentation services
            var presentationServices = container.GetExportedValues<IPresentationService>();
            foreach (var presentationService in presentationServices) { presentationService.Initialize(); }
            
            // Initialize and run all module controllers
            moduleControllers = container.GetExportedValues<IModuleController>();
            foreach (var moduleController in moduleControllers) { moduleController.Initialize(); }
            foreach (var moduleController in moduleControllers) { moduleController.Run(); }
        }
开发者ID:jbe2277,项目名称:waf,代码行数:31,代码来源:App.xaml.cs

示例3: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

#if !(DEBUG)
            DispatcherUnhandledException += AppDispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;
#endif

            InitializeCultures();

            catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(WafConfiguration).Assembly));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(ShellViewModel).Assembly));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(App).Assembly));

            container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection);
            CompositionBatch batch = new CompositionBatch();
            batch.AddExportedValue(container);
            container.Compose(batch);

            // Initialize all presentation services
            var presentationServices = container.GetExportedValues<IPresentationService>();
            foreach (var presentationService in presentationServices) { presentationService.Initialize(); }

            // Initialize and run all module controllers
            moduleControllers = container.GetExportedValues<IModuleController>();
            foreach (var moduleController in moduleControllers) { moduleController.Initialize(); }
            foreach (var moduleController in moduleControllers) { moduleController.Run(); }
        }
开发者ID:jhorv,项目名称:dotnetpad,代码行数:30,代码来源:App.xaml.cs

示例4: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            #if (DEBUG != true)
            // Don't handle the exceptions in Debug mode because otherwise the Debugger wouldn't
            // jump into the code when an exception occurs.
            DispatcherUnhandledException += AppDispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;
            #endif

            catalog = new AggregateCatalog();
            // Add the WpfApplicationFramework assembly to the catalog
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(Controller).Assembly));

            // Load module assemblies as well. See App.config file.
            foreach (string moduleAssembly in Settings.Default.ModuleAssemblies)
            {
                catalog.Catalogs.Add(new AssemblyCatalog(moduleAssembly));
            }

            container = new CompositionContainer(catalog);
            CompositionBatch batch = new CompositionBatch();
            batch.AddExportedValue(container);
            container.Compose(batch);

            // Initialize all presentation services
            var presentationServices = container.GetExportedValues<IPresentationService>();
            foreach (var presentationService in presentationServices) { presentationService.Initialize(); }

            // Initialize and run all module controllers
            moduleControllers = container.GetExportedValues<IModuleController>();
            foreach (var moduleController in moduleControllers) { moduleController.Initialize(); }
            foreach (var moduleController in moduleControllers) { moduleController.Run(); }
        }
开发者ID:hliang89,项目名称:WpfApplicationFramework,代码行数:35,代码来源:App.xaml.cs

示例5: Initialize

        internal static void Initialize(CompositionContainer composition)
        {
            List<Language> languages = new List<Language>();
            if (composition != null)
                languages.AddRange(composition.GetExportedValues<Language>());
            else {
                languages.Add(new CSharpLanguage());
                languages.Add(new VB.VBLanguage());
            }

            // Fix order: C#, VB, IL
            var langs2 = new List<Language>();
            var lang = languages.FirstOrDefault(a => a is CSharpLanguage);
            if (lang != null) {
                languages.Remove(lang);
                langs2.Add(lang);
            }
            lang = languages.FirstOrDefault(a => a is VB.VBLanguage);
            if (lang != null) {
                languages.Remove(lang);
                langs2.Add(lang);
            }
            langs2.Add(new ILLanguage(true));
            for (int i = 0; i < langs2.Count; i++)
                languages.Insert(i, langs2[i]);

            #if DEBUG
            languages.AddRange(ILAstLanguage.GetDebugLanguages());
            languages.AddRange(CSharpLanguage.GetDebugLanguages());
            #endif
            allLanguages = languages.AsReadOnly();
        }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:32,代码来源:Languages.cs

示例6: GetUploadHandlers

 private static IList<IUploadHandler> GetUploadHandlers(IApplicationSettings settings)
 {
     // Use MEF to locate the content providers in this assembly
     var compositionContainer = new CompositionContainer(new AssemblyCatalog(typeof(UploadProcessor).Assembly));
     compositionContainer.ComposeExportedValue<IApplicationSettings>(settings);
     return compositionContainer.GetExportedValues<IUploadHandler>().ToList();
 }
开发者ID:jaspertheisen,项目名称:JabbR,代码行数:7,代码来源:UploadProcessor.cs

示例7: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            DispatcherUnhandledException += AppDispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;

            catalog = new AggregateCatalog();
            // Add the WpfApplicationFramework assembly to the catalog
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(ViewModel).Assembly));
            // Add the Waf.BookLibrary.Library.Presentation assembly to the catalog
            catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
            // Add the Waf.BookLibrary.Library.Applications assembly to the catalog
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(ShellViewModel).Assembly));

            // Load module assemblies as well (e.g. Reporting extension). See App.config file.
            foreach(string moduleAssembly in Settings.Default.ModuleAssemblies)
            {
                catalog.Catalogs.Add(new AssemblyCatalog(moduleAssembly));
            }

            container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection);
            CompositionBatch batch = new CompositionBatch();
            batch.AddExportedValue(container);
            container.Compose(batch);

            moduleControllers = container.GetExportedValues<IModuleController>();
            foreach (IModuleController moduleController in moduleControllers) { moduleController.Initialize(); }
            foreach (IModuleController moduleController in moduleControllers) { moduleController.Run(); }
        }
开发者ID:bensenplus,项目名称:breeze,代码行数:30,代码来源:App.xaml.cs

示例8: SarifTraceListener

 static SarifTraceListener()
 {
     AggregateCatalog catalog = new AggregateCatalog();
     catalog.Catalogs.Add(new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()));
     CompositionContainer container = new CompositionContainer(catalog);
     SarifTraceListener.Rules = container.GetExportedValues<IRuleDescriptor>();
 }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:7,代码来源:SarifTraceListener.cs

示例9: DiscoverServices

        public void DiscoverServices(IServicePool pool)
        {
            var registration = new RegistrationBuilder();

            registration.ForTypesDerivedFrom<IService>().SelectConstructor((ConstructorInfo[] cInfo) =>
            {
                if (cInfo.Length == 0)
                    return null;
                return cInfo[0];
            }).Export<IService>();

            var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            var catalog = new DirectoryCatalog(path, registration);
            var container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection);
            var services = container.GetExportedValues<IService>();

            foreach (var service in services)
            {
                service.ServicePool = pool;
                var interfaces = service.GetType().GetInterfaces();
                Type interfaceType = null;
                foreach (var i in interfaces)
                {
                    var name = i.FullName;
                    if (!name.Contains("Contracts.IService") && !name.Contains("System."))
                    {
                        interfaceType = i;
                        break;
                    }
                }
                pool.AddService(interfaceType, service);
            }
        }
开发者ID:nagyistoce,项目名称:ArchitectureCampSample,代码行数:33,代码来源:ServiceDiscoveryService.cs

示例10: GetSpells

 private static IList<ISpellCast> GetSpells()
 {
     // Use MEF to locate the content providers in this assembly
     var catalog = new AssemblyCatalog(typeof(SpellManager).Assembly);
     var compositionContainer = new CompositionContainer(catalog);
     return compositionContainer.GetExportedValues<ISpellCast>().ToList();
 }
开发者ID:bbqchickenrobot,项目名称:Legend,代码行数:7,代码来源:SpellManager.cs

示例11: Plugins

        /// <summary>
        /// Static Initialization for loading the plugins into the ApplicationPlugins Collection
        /// </summary>
        static Plugins()
        {
            var catalog = new AggregateCatalog();

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


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

            string programpath = Path.GetDirectoryName(programassembly);

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

            _container = new CompositionContainer(catalog);

            try
            {
                ApplicationPlugins = _container.GetExportedValues<IWPFApplicationPlugin>();
            }
            catch (CompositionException compositionException)
            {
                throw compositionException;
            }

        }
开发者ID:kiszu,项目名称:ForBlog,代码行数:30,代码来源:Plugins.cs

示例12: CacheFactory

 static CacheFactory()
 {
     AggregateCatalog catalog = new AggregateCatalog();
     catalog.Catalogs.Add(new AssemblyCatalog(typeof(ICache).Assembly));
     CompositionContainer container = new CompositionContainer(catalog);
     caches = container.GetExportedValues<ICache>();
 }
开发者ID:JordanRift,项目名称:Grassroots,代码行数:7,代码来源:CacheFactory.cs

示例13: GetIoCContainer

        private static TinyIoCContainer GetIoCContainer()
        {
            var container = new TinyIoCContainer();

            //Configuration Values
            var redisToGoUrl = ConfigurationManager.AppSettings["REDISTOGO_URL"];
            var botName = ConfigurationManager.AppSettings["BotName"];

            //Using MEF to build-up instances
            var commandProcessorCompositionContainer = new CompositionContainer(new AssemblyCatalog(typeof(ICommandProcessor).Assembly));
            var commandProcessors = commandProcessorCompositionContainer.GetExportedValues<ICommandProcessor>();
            var contentProviderCompositionContainer = new CompositionContainer(new AssemblyCatalog(typeof(IContentProvider).Assembly));
            var contentProviders = contentProviderCompositionContainer.GetExportedValues<IContentProvider>();

            //Bootstrapper Tasks
            container.Register<IBootstrapperPerInstanceTask, RegisterErrorHandling>("RegisterErrorHandling");
            container.Register<IBootstrapperPerApplicationTask, Bundles>("Bundles");
            container.Register<IBootstrapperPerApplicationTask, RegisterRoutes>("RegisterRoutes");
            container.Register<Func<ChatHub>>((c, p) => () => c.Resolve<ChatHub>());
            container.Register<IBootstrapperPerApplicationTask, RegisterSignalRDependencies>("RegisterSignalRDependencies");
            //Domain
            container.Register<string>((c, p) => botName);
            container.Register<IEnumerable<ICommandProcessor>>(commandProcessors); //Singleton
            container.Register<IEnumerable<IContentProvider>>(contentProviders); //Singleton
            container.Register<IMessageStore>((c, p) => new RedisMessageStore(0, redisToGoUrl)); //Multi-instance
            container.Register<IUserStore>((c, p) => new RedisUserStore(0, redisToGoUrl)); //Multi-instance
            container.Register<ChatHub>(); //Multi-instance

            return container;
        }
开发者ID:IngageNetworks,项目名称:IN.Chat,代码行数:30,代码来源:Bootstrapper.cs

示例14: FileSaveServiceFactory

 static FileSaveServiceFactory()
 {
     AggregateCatalog catalog = new AggregateCatalog();
     catalog.Catalogs.Add(new AssemblyCatalog(typeof(IFileSaveService).Assembly));
     CompositionContainer container = new CompositionContainer(catalog);
     services = container.GetExportedValues<IFileSaveService>();
 }
开发者ID:JordanRift,项目名称:Grassroots,代码行数:7,代码来源:FileSaveServiceFactory.cs

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


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