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


C# ContainerConfiguration.CreateContainer方法代码示例

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


在下文中一共展示了ContainerConfiguration.CreateContainer方法的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: 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

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

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

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

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

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

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

示例9: Bootstrapper

 public void Bootstrapper()
 {
     var configuration = new ContainerConfiguration()
         .WithPart<Calculator>();
     using (CompositionHost host = configuration.CreateContainer())
     {
         // Calculator = host.GetExport<ICalculator>();
         host.SatisfyImports(this);
     }
 }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:10,代码来源:Program.cs

示例10: Compose

        protected void Compose()
        {
            // Create the container
            var config = new ContainerConfiguration();
            ConfigureContainer(config);
            _container = config.CreateContainer();

            // Compose the application
            _container.SatisfyImports(this);
        }
开发者ID:anurse,项目名称:AppRT,代码行数:10,代码来源:Application.cs

示例11: OnInitialize

        protected override void OnInitialize()
        {
            base.OnInitialize();

            Context = UnitTestSynchronizationContext.Create();

            var configuration = new ContainerConfiguration()
                .WithAssembly(typeof(ShellViewModel).GetTypeInfo().Assembly)
                .WithAssembly(typeof(ApplicationsTest).GetTypeInfo().Assembly);
            Container = configuration.CreateContainer();
        }
开发者ID:jbe2277,项目名称:waf,代码行数:11,代码来源:ApplicationsTest.cs

示例12: Main

		private static void Main(string[] args) {
			var configuration = new ContainerConfiguration()
				.WithAssembly(typeof(Channel).Assembly)
				.WithPart(typeof(DesktopCryptoProvider))
				.WithPart(typeof(DesktopChannel))
				.WithPart(typeof(Program));
			var container = configuration.CreateContainer();
			
			var program = container.GetExport<Program>();
			program.DoAsync().GetAwaiter().GetResult();
		}
开发者ID:raam030,项目名称:IronPigeon,代码行数:11,代码来源:Program.cs

示例13: Prepare

        public override void Prepare()
        {
            var config = new ContainerConfiguration();

            RegisterBasic(config);
            
            RegisterPropertyInjection(config);
            RegisterMultiple(config);
            RegisterOpenGeneric(config);

            this.container = config.CreateContainer();
        }
开发者ID:CodeDux,项目名称:IocPerformance,代码行数:12,代码来源:Mef2ContainerAdapter.cs

示例14: ShouldForwardResolveToInnerContainerWhenKeyIsUsed

        public void ShouldForwardResolveToInnerContainerWhenKeyIsUsed()
        {
            object myInstance = new object();

            ContainerConfiguration config = new ContainerConfiguration();
            config.WithExport<object>(myInstance, "key");
            MefServiceLocatorAdapter.CompositionContainer = config.CreateContainer();

            IServiceLocator containerAdapter = new MefServiceLocatorAdapter();

            Assert.AreSame(myInstance, containerAdapter.GetInstance(typeof(object), "key"));
        }
开发者ID:xperiandri,项目名称:PortablePrism,代码行数:12,代码来源:MefServiceLocatorAdapterFixture.cs

示例15: GetContainer

        /// <summary>
        /// <see cref="CompositionContext"/>生成
        /// </summary>
        /// <returns></returns>
        private static CompositionContext GetContainer()
        {
            var config = new ContainerConfiguration();
            config.WithAssembly(typeof(Program).Assembly);

            //var builder = new ConventionBuilder();
            //builder.ForType<Logger>().Export<ILogger>();
            //config.WithAssembly(typeof(Program).Assembly, builder);

            config.WithProvider(new LogExportDescriptorProvider());

            return config.CreateContainer();
        }
开发者ID:yasu-s,项目名称:MEF-Sample,代码行数:17,代码来源:Program.cs


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