本文整理汇总了C#中Container.BuildUp方法的典型用法代码示例。如果您正苦于以下问题:C# Container.BuildUp方法的具体用法?C# Container.BuildUp怎么用?C# Container.BuildUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container.BuildUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DifferentObjects_BuildUpInterfaceWithManyInterfaceDependencyMethods_Success
public void DifferentObjects_BuildUpInterfaceWithManyInterfaceDependencyMethods_Success()
{
var c = new Container();
c.RegisterType<IEmptyClass, EmptyClass>();
c.RegisterType<ISampleClassWithInterfaceAsParameter, SampleClassWithInterfaceAsParameter>().AsSingleton();
ISampleClassWithManyInterfaceDependencyMethods sampleClass1 = new SampleClassWithManyInterfaceDependencyMethods();
ISampleClassWithManyInterfaceDependencyMethods sampleClass2 = new SampleClassWithManyInterfaceDependencyMethods();
c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction);
c.BuildUp(sampleClass2, ResolveKind.PartialEmitFunction);
Assert.IsNotNull(sampleClass1.EmptyClass);
Assert.IsNotNull(sampleClass1.SampleClass);
Assert.IsNotNull(sampleClass1.SampleClass.EmptyClass);
Assert.AreNotEqual(sampleClass1.SampleClass.EmptyClass, sampleClass1.EmptyClass);
Assert.IsNotNull(sampleClass2.EmptyClass);
Assert.IsNotNull(sampleClass2.SampleClass);
Assert.IsNotNull(sampleClass2.SampleClass.EmptyClass);
Assert.AreNotEqual(sampleClass2.SampleClass.EmptyClass, sampleClass2.EmptyClass);
Assert.AreNotEqual(sampleClass1, sampleClass2);
Assert.AreNotEqual(sampleClass1.EmptyClass, sampleClass2.EmptyClass);
Assert.AreEqual(sampleClass1.SampleClass, sampleClass2.SampleClass);
Assert.AreEqual(sampleClass1.SampleClass.EmptyClass, sampleClass2.SampleClass.EmptyClass);
}
示例2: Container
public void DifferentThreads_DifferentObjects_RegisterClassWithDependencyPropertyAndDependencyMethodWithDifferentTypes_Success()
{
var c = new Container();
c.RegisterType<IEmptyClass, EmptyClass>().AsPerThread();
c.RegisterType<ISampleClassWithInterfaceAsParameter, SampleClassWithInterfaceAsParameter>().AsPerThread();
ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes sampleClass1 = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes();
ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes sampleClass2 = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes();
var thread1 = new Thread(() => { c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction); });
thread1.Start();
thread1.Join();
var thread2 = new Thread(() => { c.BuildUp(sampleClass2, ResolveKind.PartialEmitFunction); });
thread2.Start();
thread2.Join();
Assert.IsNotNull(sampleClass1.SampleClass);
Assert.IsNotNull(sampleClass1.EmptyClass);
Assert.AreNotEqual(sampleClass1.SampleClass, sampleClass1.EmptyClass);
Assert.AreEqual(sampleClass1.SampleClass.EmptyClass, sampleClass1.EmptyClass);
Assert.IsNotNull(sampleClass2.SampleClass);
Assert.IsNotNull(sampleClass2.EmptyClass);
Assert.AreNotEqual(sampleClass2.SampleClass, sampleClass2.EmptyClass);
Assert.AreEqual(sampleClass2.SampleClass.EmptyClass, sampleClass2.EmptyClass);
Assert.AreNotEqual(sampleClass1, sampleClass2);
Assert.AreNotEqual(sampleClass1.SampleClass, sampleClass2.SampleClass);
Assert.AreNotEqual(sampleClass1.EmptyClass, sampleClass2.EmptyClass);
}
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:27,代码来源:BuildUpForInterfaceWithDependencyPropertyAndDependencyMethodTests.cs
示例3: DifferentThreads_DifferentObjects_RegisterClassWithDependencyPropertyAndDependencyMethod_Success
public void DifferentThreads_DifferentObjects_RegisterClassWithDependencyPropertyAndDependencyMethod_Success()
{
var c = new Container();
c.RegisterType<EmptyClass>().AsPerThread();
var sampleClass1 = new SampleClassWithClassDependencyPropertyAndDependencyMethodWithSameType();
var sampleClass2 = new SampleClassWithClassDependencyPropertyAndDependencyMethodWithSameType();
var thread1 = new Thread(() =>
{
c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction);
});
thread1.Start();
thread1.Join();
var thread2 = new Thread(() =>
{
c.BuildUp(sampleClass2, ResolveKind.PartialEmitFunction);
});
thread2.Start();
thread2.Join();
Assert.IsNotNull(sampleClass1.EmptyClassFromDependencyProperty);
Assert.IsNotNull(sampleClass1.EmptyClassFromDependencyMethod);
Assert.AreEqual(sampleClass1.EmptyClassFromDependencyProperty, sampleClass1.EmptyClassFromDependencyMethod);
Assert.IsNotNull(sampleClass2.EmptyClassFromDependencyProperty);
Assert.IsNotNull(sampleClass2.EmptyClassFromDependencyMethod);
Assert.AreEqual(sampleClass2.EmptyClassFromDependencyProperty, sampleClass2.EmptyClassFromDependencyMethod);
Assert.AreNotEqual(sampleClass1, sampleClass2);
Assert.AreNotEqual(sampleClass1.EmptyClassFromDependencyProperty, sampleClass2.EmptyClassFromDependencyMethod);
Assert.AreNotEqual(sampleClass1.EmptyClassFromDependencyMethod, sampleClass2.EmptyClassFromDependencyMethod);
}
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:30,代码来源:BuildUpForClassWithDependencyPropertyAndDependencyMethodTests.cs
示例4: DifferentObjects_BuildUpClassWithManyClassDependencyProperties_Success
public void DifferentObjects_BuildUpClassWithManyClassDependencyProperties_Success()
{
var c = new Container();
c.RegisterType<EmptyClass>();
c.RegisterType<SampleClass>().AsSingleton();
var sampleClass1 = new SampleClassWithManyClassDependencyProperties();
var sampleClass2 = new SampleClassWithManyClassDependencyProperties();
c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction);
c.BuildUp(sampleClass2, ResolveKind.PartialEmitFunction);
Assert.IsNotNull(sampleClass1.EmptyClass);
Assert.IsNotNull(sampleClass1.SampleClass);
Assert.IsNotNull(sampleClass1.SampleClass.EmptyClass);
Assert.AreNotEqual(sampleClass1.SampleClass.EmptyClass, sampleClass1.EmptyClass);
Assert.IsNotNull(sampleClass2.EmptyClass);
Assert.IsNotNull(sampleClass2.SampleClass);
Assert.IsNotNull(sampleClass2.SampleClass.EmptyClass);
Assert.AreNotEqual(sampleClass2.SampleClass.EmptyClass, sampleClass2.EmptyClass);
Assert.AreNotEqual(sampleClass1, sampleClass2);
Assert.AreNotEqual(sampleClass1.EmptyClass, sampleClass2.EmptyClass);
Assert.AreEqual(sampleClass1.SampleClass, sampleClass2.SampleClass);
Assert.AreEqual(sampleClass1.SampleClass.EmptyClass, sampleClass2.SampleClass.EmptyClass);
}
示例5: BuildUpClassWithDependencyProperty_Fail
public void BuildUpClassWithDependencyProperty_Fail()
{
var c = new Container();
c.RegisterType<EmptyClass>().AsSingleton();
var sampleClass = new SampleClassWithClassDependencyProperty();
Exception exception = null;
var thread = new Thread(() =>
{
try
{
c.BuildUp(sampleClass, ResolveKind.FullEmitFunction);
}
catch (Exception ex)
{
exception = ex;
}
});
thread.Start();
thread.Join();
if (exception != null)
{
throw exception;
}
Assert.IsNotNull(sampleClass.EmptyClass);
}
示例6: BuildUpInterfaceWithDependencyMethodWithoutRegisteredNestedClass_Failed
public void BuildUpInterfaceWithDependencyMethodWithoutRegisteredNestedClass_Failed()
{
var c = new Container();
ISampleClassWithInterfaceMethod sampleClass = new SampleClassWithInterfaceDependencyMethod();
c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction);
}
示例7: BuildUpInterfaceWithDependencyPropertyWithoutRegisteredNestedClass_Success
public void BuildUpInterfaceWithDependencyPropertyWithoutRegisteredNestedClass_Success()
{
var c = new Container();
ISampleClassWithInterfaceProperty sampleClass = new SampleClassWithInterfaceDependencyProperty();
c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction);
Assert.IsNotNull(sampleClass.EmptyClass);
}
示例8: BuildUpInterfaceWithDependencyMethod_Success
public void BuildUpInterfaceWithDependencyMethod_Success()
{
var c = new Container();
c.RegisterType<IEmptyClass, EmptyClass>().AsSingleton();
ISampleClassWithInterfaceMethod sampleClass = new SampleClassWithInterfaceDependencyMethod();
c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction);
Assert.IsNotNull(sampleClass.EmptyClass);
}
示例9: BuildUpClassWithDependencyProperty_Fail
public void BuildUpClassWithDependencyProperty_Fail()
{
var c = new Container();
c.RegisterType<EmptyClass>().AsSingleton();
var sampleClass = new SampleClassWithClassDependencyProperty();
c.BuildUp(sampleClass, ResolveKind.FullEmitFunction);
Assert.IsNotNull(sampleClass.EmptyClass);
}
示例10: BuildUpInterfaceWithDependencyMethodWithReturnType_Failed
public void BuildUpInterfaceWithDependencyMethodWithReturnType_Failed()
{
var c = new Container();
c.RegisterType<IEmptyClass, EmptyClass>();
ISampleClassWithInterfaceMethodWithReturnType sampleClass = new SampleClassWithInterfaceDependencyMethodWithReturnType();
c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction);
Assert.IsNull(sampleClass.EmptyClass);
}
示例11: BuildUpClassWithDependencyMethodWithReturnType_Failed
public void BuildUpClassWithDependencyMethodWithReturnType_Failed()
{
var c = new Container();
c.RegisterType<EmptyClass>().AsSingleton();
var sampleClass = new SampleClassWithClassDependencyMethodWithReturnType();
c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction);
Assert.IsNull(sampleClass.EmptyClass);
}
示例12: BuildUpInterfaceWithoutDependencyProperty_Fail
public void BuildUpInterfaceWithoutDependencyProperty_Fail()
{
var c = new Container();
c.RegisterType<IEmptyClass, EmptyClass>().AsSingleton();
ISampleClassWithInterfaceProperty sampleClass = new SampleClassWithoutInterfaceDependencyProperty();
c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction);
Assert.IsNull(sampleClass.EmptyClass);
}
示例13: BuildUpClassWithDependencyMethod_Success
public void BuildUpClassWithDependencyMethod_Success()
{
var c = new Container();
c.RegisterType<EmptyClass>();
var sampleClass = new SampleClassWithClassDependencyMethod();
c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction);
Assert.IsNotNull(sampleClass.EmptyClass);
}
示例14: DifferentObjects_RegisterClassWithDependencyPropertyAndDependencyMethod_Success
public void DifferentObjects_RegisterClassWithDependencyPropertyAndDependencyMethod_Success()
{
var c = new Container();
c.RegisterType<IEmptyClass, EmptyClass>().AsSingleton();
ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithSameType sampleClass1 = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithSameType();
ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithSameType sampleClass2 = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithSameType();
c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction);
c.BuildUp(sampleClass2, ResolveKind.PartialEmitFunction);
Assert.IsNotNull(sampleClass1.EmptyClassFromDependencyProperty);
Assert.IsNotNull(sampleClass1.EmptyClassFromDependencyMethod);
Assert.AreEqual(sampleClass1.EmptyClassFromDependencyProperty, sampleClass1.EmptyClassFromDependencyMethod);
Assert.IsNotNull(sampleClass2.EmptyClassFromDependencyProperty);
Assert.IsNotNull(sampleClass2.EmptyClassFromDependencyMethod);
Assert.AreEqual(sampleClass2.EmptyClassFromDependencyProperty, sampleClass2.EmptyClassFromDependencyMethod);
Assert.AreNotEqual(sampleClass1, sampleClass2);
Assert.AreEqual(sampleClass1.EmptyClassFromDependencyProperty, sampleClass2.EmptyClassFromDependencyMethod);
Assert.AreEqual(sampleClass1.EmptyClassFromDependencyMethod, sampleClass2.EmptyClassFromDependencyMethod);
}
开发者ID:amularczyk,项目名称:NiquIoC,代码行数:20,代码来源:BuildUpForInterfaceWithDependencyPropertyAndDependencyMethodTests.cs
示例15: BuildUpClassWithDependencyMethodWithReturnType_Failed
public void BuildUpClassWithDependencyMethodWithReturnType_Failed()
{
var c = new Container();
c.RegisterType<EmptyClass>().AsPerThread();
var sampleClass = new SampleClassWithClassDependencyMethodWithReturnType();
var thread = new Thread(() => { c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction); });
thread.Start();
thread.Join();
Assert.IsNull(sampleClass.EmptyClass);
}