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


C# ContainerConfiguration.WithProvider方法代码示例

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


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

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

示例2: ConfigureMef

        public static CompositionHost ConfigureMef(IServiceProvider serviceProvider,
                                                   OmniSharpOptions options,
                                                   IEnumerable<Assembly> assemblies,
                                                   Func<ContainerConfiguration, ContainerConfiguration> configure = null)
        {
            var config = new ContainerConfiguration();
            assemblies = assemblies
                .Concat(new[] { typeof(OmnisharpWorkspace).GetTypeInfo().Assembly, typeof(IRequest).GetTypeInfo().Assembly })
                .Distinct();

            foreach (var assembly in assemblies)
            {
                config = config.WithAssembly(assembly);
            }

            var memoryCache = serviceProvider.GetService<IMemoryCache>();
            var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
            var env = serviceProvider.GetService<IOmnisharpEnvironment>();
            var writer = serviceProvider.GetService<ISharedTextWriter>();
            var applicationLifetime = serviceProvider.GetService<IApplicationLifetime>();
            var loader = serviceProvider.GetService<IOmnisharpAssemblyLoader>();

            config = config
                .WithProvider(MefValueProvider.From(serviceProvider))
                .WithProvider(MefValueProvider.From<IFileSystemWatcher>(new ManualFileSystemWatcher()))
                .WithProvider(MefValueProvider.From(memoryCache))
                .WithProvider(MefValueProvider.From(loggerFactory))
                .WithProvider(MefValueProvider.From(env))
                .WithProvider(MefValueProvider.From(writer))
                .WithProvider(MefValueProvider.From(applicationLifetime))
                .WithProvider(MefValueProvider.From(options))
                .WithProvider(MefValueProvider.From(options.FormattingOptions))
                .WithProvider(MefValueProvider.From(loader))
                .WithProvider(MefValueProvider.From(new MetadataHelper(loader))); // other way to do singleton and autowire?

            if (env.TransportType == TransportType.Stdio)
            {
                config = config
                    .WithProvider(MefValueProvider.From<IEventEmitter>(new StdioEventEmitter(writer)));
            }
            else
            {
                config = config
                    .WithProvider(MefValueProvider.From<IEventEmitter>(new NullEventEmitter()));
            }

            if (configure != null)
                config = configure(config);

            var container = config.CreateContainer();
            return container;
        }
开发者ID:RLittlesII,项目名称:omnisharp-roslyn,代码行数:52,代码来源:Startup.cs

示例3: Get

		public override ContainerConfiguration Get( ContainerConfiguration parameter ) => parameter.WithProvider( ServicesExportDescriptorProvider.Default );
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:1,代码来源:ContainerServicesConfigurator.cs

示例4: WithExportProviders

 public virtual ContainerConfiguration WithExportProviders(ContainerConfiguration configuration)
 {
     configuration.WithProvider(new ExportFactoryExportDescriptorProvider());
     configuration.WithProvider(new ExportFactoryWithMetadataExportDescriptorProvider());
     return configuration;
 }
开发者ID:movileanubeniamin,项目名称:kephas,代码行数:6,代码来源:CompositionTestBase.cs


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