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


C# ContainerConfiguration类代码示例

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


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

示例1: Init

        /// <summary>
        /// 遅延初期化処理。
        /// </summary>
        /// <param name="token"></param>
        private void Init(CancellationToken token, TaskScheduler uiSyncContext, Assembly callerAssembly)
        {
            logger.Trace("Init Start");
            try
            {
                // MEFの構成
                var qAssm = new[] { 
                    this.GetType().Assembly,
                    Assembly.GetEntryAssembly(),
                    callerAssembly, 
                    typeof(Pasta.Logging.PastaLogger).Assembly,
                    typeof(Pasta.Gleaners.Net.MailGleaner).Assembly,
                }
                    .Where(a => a != null)
                    .Distinct();
                var configuration = new ContainerConfiguration()
                    .WithAssemblies(qAssm)
                    ;
                var host = configuration.CreateContainer();
                token.Register(() => host.Dispose());

                // appの取得と構成
                var app = host.GetExport<AppCore>();
                app.Init(token,uiSyncContext);
                Application = app;
                logger.Trace("Init End");
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
开发者ID:ekicyou,项目名称:pasta,代码行数:36,代码来源:AppLoader.cs

示例2: Basic

		public void Basic()
		{
			var types = new[] { typeof(Singleton) }.AsApplicationParts();
			var container = new ContainerConfiguration().WithParts( types.AsEnumerable() ).WithProvider( SingletonExportDescriptorProvider.Default ).CreateContainer();
			var export = container.GetExport<Singleton>();
			Assert.Same( Singleton.Default, export );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:7,代码来源:SingletonExportDescriptorProviderTests.cs

示例3: Implementation

		public void Implementation()
		{
			var types = new[] { typeof(Implemented) }.AsApplicationParts();
			var container = new ContainerConfiguration().WithParts( types.AsEnumerable() ).WithProvider( SingletonExportDescriptorProvider.Default ).CreateContainer();
			Assert.Same( Implemented.Default, container.GetExport<ISingleton>() );
			Assert.Same( Implemented.Default, container.GetExport<Implemented>() );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:7,代码来源:SingletonExportDescriptorProviderTests.cs

示例4: ConfigureContainer

        public static void ConfigureContainer()
        {
            var containerConventions = new ConventionBuilder();

            containerConventions.ForType<DbProductRepository>()
                .ExportInterfaces()
                .SelectConstructorWithMostParameters()
                .InstancePerHttpRequest();

            containerConventions.ForType<DbLogger>()
                .ExportInterfaces()
                .SelectConstructorWithMostParameters()
                .InstancePerHttpRequest();

            containerConventions.ForType<ProductDbContext>()
                .Export()
                .InstancePerHttpRequest();

            containerConventions.ForTypesDerivedFrom<Controller>()
                .Export<IController>()
                .Export()
                .SelectConstructorWithMostParameters();

            var containerConfig = new ContainerConfiguration();
            containerConfig.WithAssembly(Assembly.GetExecutingAssembly(), containerConventions);

            containerConfig.CreateContainer().UseWithMvc();
        }
开发者ID:Hem,项目名称:MvcMefProvider,代码行数:28,代码来源:MefContainer.cs

示例5: StandardExportInterfacesShouldWork

        public void StandardExportInterfacesShouldWork()
        {
            // Export all interfaces except IDisposable, Export contracts on types without interfaces. except for disposable types
            var builder = new ConventionBuilder();
            builder.ForTypesMatching((t) => true).ExportInterfaces();
            builder.ForTypesMatching((t) => t.GetTypeInfo().ImplementedInterfaces.Where((iface) => iface != typeof(System.IDisposable)).Count() == 0).Export();

            var container = new ContainerConfiguration()
                .WithPart<Standard>(builder)
                .WithPart<Dippy>(builder)
                .WithPart<Derived>(builder)
                .WithPart<BareClass>(builder)
                .CreateContainer();

            var importer = new Importer();
            container.SatisfyImports(importer);

            Assert.NotNull(importer.First);
            Assert.True(importer.First.Count() == 3);
            Assert.NotNull(importer.Second);
            Assert.True(importer.Second.Count() == 3);
            Assert.NotNull(importer.Third);
            Assert.True(importer.Third.Count() == 3);
            Assert.NotNull(importer.Fourth);
            Assert.True(importer.Fourth.Count() == 3);
            Assert.NotNull(importer.Fifth);
            Assert.True(importer.Fifth.Count() == 3);

            Assert.Null(importer.Base);
            Assert.Null(importer.Derived);
            Assert.Null(importer.Dippy);
            Assert.Null(importer.Standard);
            Assert.Null(importer.Disposable);
            Assert.NotNull(importer.BareClass);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:35,代码来源:PartBuilderInterfaceTests.cs

示例6: CompleteInitialization

        public static void CompleteInitialization()
        {
            Assembly[] partsAssemblies;

            lock (_initLock)
            {
                if (_isInitialized)
                    return;

                _isInitialized = true;

                partsAssemblies = _partAssemblies.Union(FindWebApplicationAssemblies()).ToArray();
            }

            var conventions = new ConventionBuilder()
                .WithMvcConventions()
                .WithEagerConstructionSupport();

            conventions.ForTypesUnderNamespace("Parts").Export().ExportInterfaces();

            var container = new ContainerConfiguration()
                .WithDefaultConventions(conventions)
                .WithAssemblies(partsAssemblies)
                .WithApplicationSettings()
                .CreateContainer();

            MvcCompositionProvider.Initialize(container);
            CompositionFilterProvider.Install(FilterProviders.Providers);
            ImportCapableFilterAttributeFilterProvider.Install(FilterProviders.Providers);

            container.ConstructEagerParts();
        }
开发者ID:blinds52,项目名称:alt-composition,代码行数:32,代码来源:CompositionProvider.cs

示例7: QueryProviders

 public void QueryProviders(IEnumerable<Assembly> assemblies)
 {
     var configuration = new ContainerConfiguration().WithAssemblies(assemblies);
     using (var container = configuration.CreateContainer())
     {
         container.SatisfyImports(this);
     }
 }
开发者ID:arielbh,项目名称:SuiteValue.UI.Metro,代码行数:8,代码来源:AuthManager.cs

示例8: InitializeContainer

 public void InitializeContainer(params Type[] parts)
 {
     var configuration = new ContainerConfiguration().WithParts(parts);
     using (CompositionHost host = configuration.CreateContainer())
     {
         host.SatisfyImports(_calcImport);
     }
 }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:8,代码来源:CalculatorManager.cs

示例9: Many

		public void Many()
		{
			var types = new[] { typeof(Implemented), typeof(AnotherImplemented) }.AsApplicationParts();
			var container = new ContainerConfiguration().WithParts( types.AsEnumerable() ).WithProvider( SingletonExportDescriptorProvider.Default ).CreateContainer();
			var exports = container.GetExports<ISingleton>().Fixed();
			Assert.Contains( Implemented.Default, exports );
			Assert.Contains( AnotherImplemented.Default, exports );
		}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:8,代码来源:SingletonExportDescriptorProviderTests.cs

示例10: CreateContainer

        private CompositionContext CreateContainer(params Type[] types)
        {
            var configuration = new ContainerConfiguration()
                .WithParts(types)
                .WithProvider(new DictionaryExportDescriptorProvider());

            return configuration.CreateContainer();
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:DictionaryImportTests.cs

示例11: BuildLocator

        private static IServiceLocator BuildLocator()
        {
            var configuration = new ContainerConfiguration();
            configuration.RegisterComponents(typeof(IFoo).Assembly);

            var container = configuration.CreateContainer();

            return new MefServiceLocator(container);
        }
开发者ID:netfx,项目名称:CommonComposition,代码行数:9,代码来源:MicrosoftMefFixture.cs

示例12: GetContainer

 private CompositionHost GetContainer(IEnumerable<Assembly> assemblies)
 {
     var configuration = new ContainerConfiguration();
     foreach (var assembly in assemblies)
     {
         configuration.WithAssembly(assembly);
     }
     return configuration.CreateContainer();
 }
开发者ID:yonglehou,项目名称:docfx,代码行数:9,代码来源:DocumentBuilder.cs

示例13: MainPage

        public MainPage()
        {
            var containerConfiguration = new ContainerConfiguration().WithAssembly(typeof(App).GetTypeInfo().Assembly);
            CompositionHost host = containerConfiguration.CreateContainer();
            host.SatisfyImports(this);

            this.InitializeComponent();
            this.Loaded += MainPage_Loaded;
        }
开发者ID:aboimpinto,项目名称:GOT.Prolegis,代码行数:9,代码来源:MainPage.xaml.cs

示例14: ProvidersCanDetectAbsenceOfAContractItSupports

        public void ProvidersCanDetectAbsenceOfAContractItSupports()
        {
            var container = new ContainerConfiguration()
                .WithProvider(new DefaultObjectExportDescriptorProvider())
                .CreateContainer();

            var o = container.GetExport<object>();
            Assert.Equal(DefaultObjectExportDescriptorProvider.DefaultObject, o);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:9,代码来源:ExportDescriptorProviderTests.cs

示例15: AConcreteTypeWithDictionaryConstructorIsAMetadataView

        public void AConcreteTypeWithDictionaryConstructorIsAMetadataView()
        {
            var cc = new ContainerConfiguration()
                        .WithPart<HasNameA>()
                        .CreateContainer();

            var hn = cc.GetExport<Lazy<HasNameA, DictionaryName>>();

            Assert.Equal("A", hn.Metadata.RetrievedName);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:MetadataViewGenerationTests.cs


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