本文整理汇总了C#中ContainerConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# ContainerConfiguration类的具体用法?C# ContainerConfiguration怎么用?C# ContainerConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContainerConfiguration类属于命名空间,在下文中一共展示了ContainerConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: MetadataViewsCanCarryDefaultValues
public void MetadataViewsCanCarryDefaultValues()
{
var cc = new ContainerConfiguration()
.WithPart<HasNoName>()
.CreateContainer();
var hn = cc.GetExport<Lazy<HasNoName, OptionallyNamed>>();
Assert.Equal("B", hn.Metadata.Name);
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:MetadataViewGenerationTests.cs
示例17: EV5MefContainer
/// <summary>
/// Singleton instance of the MEF catalog
/// </summary>
//public static CompositionContainer Container { get; set; }
/// <summary>
/// Static constructor responsible to create the MEF container
/// </summary>
static EV5MefContainer()
{
var configuration = new ContainerConfiguration()
.WithAssembliesInPath(path, conventions);
//var catalog = CatalogProvider.CurrentProvider.CreateCatalog();
//Container = new CompositionContainer(catalog);
}
开发者ID:baloghp,项目名称:EV5.MVC,代码行数:18,代码来源:EV5MefContainer.cs
示例18: 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
示例19: Enumerable
public void Enumerable()
{
var parts = typeof(ExportedClass).Append( typeof(AnotherExportedClass) ).AsApplicationParts();
var container = new ContainerConfiguration().WithParts( parts.AsEnumerable() ).CreateContainer();
var exports = new ServiceLocator( container ).Get<IEnumerable<IExported>>( typeof(IEnumerable<IExported>) );
var exported = exports.WhereAssigned().Fixed();
Assert.Equal( 2, exported.Length );
Assert.Single( exported.OfType<AnotherExportedClass>() );
Assert.Single( exported.OfType<ExportedClass>() );
}
开发者ID:DevelopersWin,项目名称:VoteReporter,代码行数:10,代码来源:CompositionTests.cs
示例20: AConcreteTypeWithUnsupportedConstructorsCannotBeUsedAsAMetadataView
public void AConcreteTypeWithUnsupportedConstructorsCannotBeUsedAsAMetadataView()
{
var cc = new ContainerConfiguration()
.WithPart<HasNameA>()
.CreateContainer();
var x = Assert.Throws<CompositionFailedException>(() => cc.GetExport<Lazy<HasNoName, InvalidConcreteView>>());
Assert.Equal("The type 'InvalidConcreteView' cannot be used as a metadata view. A metadata view must be a concrete class with a parameterless or dictionary constructor.", x.Message);
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:MetadataViewGenerationTests.cs
注:本文中的ContainerConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论