本文整理汇总了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();
}
示例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;
}
示例3: Get
public override ContainerConfiguration Get( ContainerConfiguration parameter ) => parameter.WithProvider( ServicesExportDescriptorProvider.Default );
示例4: WithExportProviders
public virtual ContainerConfiguration WithExportProviders(ContainerConfiguration configuration)
{
configuration.WithProvider(new ExportFactoryExportDescriptorProvider());
configuration.WithProvider(new ExportFactoryWithMetadataExportDescriptorProvider());
return configuration;
}