本文整理汇总了C#中ContainerConfiguration.SatisfyImports方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerConfiguration.SatisfyImports方法的具体用法?C# ContainerConfiguration.SatisfyImports怎么用?C# ContainerConfiguration.SatisfyImports使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerConfiguration
的用法示例。
在下文中一共展示了ContainerConfiguration.SatisfyImports方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: SampleServicesCorrectlyImported
public void SampleServicesCorrectlyImported()
{
var container = new ContainerConfiguration()
.WithPart<SampleService1>()
.CreateContainer();
var importer = new LooseImporter();
container.SatisfyImports(importer);
Assert.Equal(1, importer.Services.Count);
}
示例3: InsideTheLambdaCallGetCustomAttributesShouldSucceed
public void InsideTheLambdaCallGetCustomAttributesShouldSucceed()
{
var builder = new ConventionBuilder();
builder.ForTypesMatching((t) => !t.GetTypeInfo().IsDefined(typeof(MyDoNotIncludeAttribute), false)).Export();
var container = new ContainerConfiguration()
.WithPart<MyNotToBeIncludedClass>(builder)
.WithPart<MyToBeIncludedClass>(builder)
.CreateContainer();
var importer = new ImporterOfMyNotTobeIncludedClass();
container.SatisfyImports(importer);
Assert.Null(importer.MyNotToBeIncludedClass);
Assert.NotNull(importer.MyToBeIncludedClass);
}
示例4: StandardExportInterfacesInterfaceFilterConfiguredContractShouldWork
public void StandardExportInterfacesInterfaceFilterConfiguredContractShouldWork()
{
//Same test as above only using default export builder
var builder = new ConventionBuilder();
builder.ForTypesMatching((t) => true).ExportInterfaces((iface) => iface != typeof(System.IDisposable), (iface, bldr) => bldr.AsContractType((Type)iface));
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);
}