本文整理汇总了C#中Microsoft.Practices.Unity.UnityContainer.AddExtension方法的典型用法代码示例。如果您正苦于以下问题:C# UnityContainer.AddExtension方法的具体用法?C# UnityContainer.AddExtension怎么用?C# UnityContainer.AddExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.Unity.UnityContainer
的用法示例。
在下文中一共展示了UnityContainer.AddExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureContainer
private static IUnityContainer ConfigureContainer(IServiceProvider package, ServiceLocatorOptions options)
{
if (package == null)
throw new ArgumentNullException(nameof(package), $"{nameof(package)} is null.");
IUnityContainer container = new UnityContainer();
container.AddExtension(new ServiceProviderUnityExtension(package, options));
container.RegisterType<IToolkit, TookitImpl>(new ContainerControlledLifetimeManager());
container.RegisterTypes(new SolutionExplorerNodeFactoryRegistrationConvention());
container.RegisterType<IEnumerable<ISolutionExplorerNodeFactory>, ISolutionExplorerNodeFactory[]>();
container.RegisterType<ISolutionExplorerNodeFactory, GlobalSolutionExplorerNodeFactory>();
container.RegisterType<ISolutionExplorer, SolutionExplorer>();
container.RegisterType<IOutputWindow, OutputWindow>(new ContainerControlledLifetimeManager());
container.RegisterType<IDialogService, DialogService>(new ContainerControlledLifetimeManager());
container.RegisterType<IEnumerable<ICommandImplementation>, ICommandImplementation[]>();
container.RegisterInstance<IServiceProvider>(package);
container.RegisterType<ICommandManager, CommandManager>(new ContainerControlledLifetimeManager());
UnityServiceLocator serviceLocator = new UnityServiceLocator(container);
container.RegisterInstance<IServiceLocator>(serviceLocator);
if (!ServiceLocator.IsLocationProviderSet)
ServiceLocator.SetLocatorProvider(() => serviceLocator);
return container;
}
示例2: ResolveLooseInterfaceTest
public void ResolveLooseInterfaceTest()
{
var container = new UnityContainer();
container.AddExtension(MockUnit.Extension);
var list = container.Resolve<IList>();
Assert.IsFalse(list.Contains(string.Empty));
}
示例3: Test
public void Test()
{
var container = new UnityContainer();
var settings = new Settings();
container.AddExtension(new Bootstrapper(settings));
container.Resolve<ProjectController>();
}
示例4: Ext_ContainerCallsExtensionsInitializeMethod
public void Ext_ContainerCallsExtensionsInitializeMethod()
{
MockContainerExtension extension = new MockContainerExtension();
IUnityContainer container = new UnityContainer();
container.AddExtension(extension);
Assert.IsTrue(extension.InitializeWasCalled);
}
示例5: CheckExtensionAdded
public void CheckExtensionAdded()
{
MyCustomExtension extension = new MyCustomExtension();
IUnityContainer uc = new UnityContainer();
uc.AddExtension(extension);
Assert.IsTrue(extension.CheckExtensionValue);
}
示例6: CheckExtensionAddedToContainer
public void CheckExtensionAddedToContainer()
{
MyCustomExtension extension = new MyCustomExtension();
IUnityContainer uc = new UnityContainer();
uc.AddExtension(extension);
Assert.AreSame(uc, extension.Container);
}
示例7: ResolveOnRegisteredTypeShouldNotBeMocked
public void ResolveOnRegisteredTypeShouldNotBeMocked()
{
var container = new UnityContainer();
container.AddExtension(MockUnit.Extension);
container.RegisterType<IMyInterface, MyClass>(new ContainerControlledLifetimeManager());
var resolved = container.Resolve<IMyInterface>();
Assert.IsNotNull(resolved);
Assert.AreEqual(typeof (MyClass), resolved.GetType());
}
示例8: ResolveLooseInterfaceWithSetupTest
public void ResolveLooseInterfaceWithSetupTest()
{
var container = new UnityContainer();
container.AddExtension(MockUnit.Extension);
var mock = MockUnit.Get<IList>();
mock.Setup(x => x.Contains(It.IsAny<string>())).Returns(true);
var list = container.Resolve<IList>();
Assert.IsTrue(list.Contains(string.Empty));
}
示例9: Register
public static IUnityContainer Register()
{
var container = new UnityContainer();
// Register types in TextUtilModule
container.AddExtension(new TextUtilModule());
return container;
}
示例10: AddExistingMyCustonExtensionToContainer
public void AddExistingMyCustonExtensionToContainer()
{
MyCustomExtension extension = new MyCustomExtension();
IUnityContainer uc = new UnityContainer();
uc.AddExtension(extension);
Assert.IsNotNull(uc);
Assert.IsTrue(extension.CheckPolicyValue);
}
示例11: Ext_ReceivesExtensionContextInInitialize
public void Ext_ReceivesExtensionContextInInitialize()
{
MockContainerExtension extension = new MockContainerExtension();
IUnityContainer container = new UnityContainer();
container.AddExtension(extension);
Assert.IsNotNull(extension.Context);
Assert.AreSame(container, extension.Context.Container);
}
示例12: CreateNewContainer
public UnityContainerAdapter CreateNewContainer()
{
IUnityContainer container = new UnityContainer();
foreach ( UnityContainerExtension extension in Extensions )
{
container.AddExtension( extension );
}
return new UnityContainerAdapter( container, InjectionMembers );
}
示例13: InstallsHandlerInstance
public void InstallsHandlerInstance()
{
// Arrange
var container = new UnityContainer();
container.RegisterInstance(new EmbeddableDocumentStore { RunInMemory = true }.Initialize());
// Act
var aggregateHandlers = new IEventHandler[] { new AggregateHandler() };
var extension = EventStoreContainerExtension.FromHandlerInstances(aggregateHandlers);
container.AddExtension(extension);
// Assert
VerifyContainer(new UnityServiceLocator(container), 1);
}
示例14: InstallsHandlerTypes
public void InstallsHandlerTypes()
{
// Arrange
var container = new UnityContainer();
container.RegisterInstance(new EmbeddableDocumentStore { RunInMemory = true }.Initialize());
// Act
var handlerTypes = new[] { typeof(AggregateHandler), typeof(AnotherAggregateHandler) };
var extension = EventStoreContainerExtension.FromHandlerTypes(handlerTypes);
container.AddExtension(extension);
// Assert
VerifyContainer(new UnityServiceLocator(container), 2);
}
示例15: Install
public static UnityContainer Install()
{
var container = new UnityContainer();
container.AddExtension(
new UnityInterfaceInterceptionRegister(
new[] { typeof(IValuesProvider), typeof(IDisposableValuesProvider) },
new IInterceptionBehavior[] { new LoggingInterceptionBehaviour() }));
container.RegisterType(typeof(IValuesProvider), typeof(ValuesProvider), new PerRequestLifetimeManager());
container.RegisterType(
typeof(IDisposableValuesProvider),
typeof(DisposableValuesProvider),
new PerRequestLifetimeManager());
container.RegisterType(typeof(System.Web.Http.Tracing.ITraceWriter), typeof(NLogger), new HierarchicalLifetimeManager());
return container;
}