本文整理汇总了C#中UnityContainer.AddExtension方法的典型用法代码示例。如果您正苦于以下问题:C# UnityContainer.AddExtension方法的具体用法?C# UnityContainer.AddExtension怎么用?C# UnityContainer.AddExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityContainer
的用法示例。
在下文中一共展示了UnityContainer.AddExtension方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainerCallsExtensionsInitializeMethod
public void ContainerCallsExtensionsInitializeMethod()
{
MockContainerExtension extension = new MockContainerExtension();
IUnityContainer container = new UnityContainer();
container.AddExtension(extension);
Assert.IsTrue(extension.InitializeWasCalled);
}
示例2: ExtensionReceivesExtensionContextInInitialize
public void ExtensionReceivesExtensionContextInInitialize()
{
MockContainerExtension extension = new MockContainerExtension();
IUnityContainer container = new UnityContainer();
container.AddExtension(extension);
Assert.IsNotNull(extension.Context);
Assert.AreSame(container, extension.Context.Container);
}
示例3: CanLookupExtensionByClassName
public void CanLookupExtensionByClassName()
{
MockContainerExtension extension = new MockContainerExtension();
IUnityContainer container = new UnityContainer();
container.AddExtension(extension);
MockContainerExtension result = container.Configure<MockContainerExtension>();
Assert.AreSame(extension, result);
}
示例4: ResolverWithElementsReturnsResolvedElementsForBaseClass
public void ResolverWithElementsReturnsResolvedElementsForBaseClass()
{
IUnityContainer container = new UnityContainer();
ILogger o1 = new MockLogger();
ILogger o2 = new SpecialLogger();
container
.RegisterInstance<ILogger>("o1", o1)
.RegisterInstance<ILogger>("o2", o2);
ResolvedArrayWithElementsResolverPolicy resolver
= new ResolvedArrayWithElementsResolverPolicy(
typeof(ILogger),
new NamedTypeDependencyResolverPolicy(typeof(ILogger), "o1"),
new NamedTypeDependencyResolverPolicy(typeof(ILogger), "o2"));
container.AddExtension(new InjectedObjectConfigurationExtension(resolver));
ILogger[] results = (ILogger[])container.Resolve<InjectedObject>().injectedValue;
Assert.IsNotNull(results);
Assert.AreEqual(2, results.Length);
Assert.AreSame(o1, results[0]);
Assert.AreSame(o2, results[1]);
}
示例5: ResolverWithElementsReturnsLiteralElements
public void ResolverWithElementsReturnsLiteralElements()
{
IUnityContainer container = new UnityContainer();
object o1 = new object();
object o2 = new object();
object o3 = new object();
container
.RegisterInstance<object>("o1", o1)
.RegisterInstance<object>("o2", o2);
ResolvedArrayWithElementsResolverPolicy resolver
= new ResolvedArrayWithElementsResolverPolicy(
typeof(object),
new LiteralValueDependencyResolverPolicy(o1),
new LiteralValueDependencyResolverPolicy(o3));
container.AddExtension(new InjectedObjectConfigurationExtension(resolver));
object[] results = (object[])container.Resolve<InjectedObject>().injectedValue;
Assert.IsNotNull(results);
Assert.AreEqual(2, results.Length);
Assert.AreSame(o1, results[0]);
Assert.AreSame(o3, results[1]);
}