当前位置: 首页>>代码示例>>C#>>正文


C# UnityContainer.AddExtension方法代码示例

本文整理汇总了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;
      }
开发者ID:modulexcite,项目名称:AlphaVSX,代码行数:31,代码来源:Toolkit.cs

示例2: ResolveLooseInterfaceTest

 public void ResolveLooseInterfaceTest()
 {
     var container = new UnityContainer();
     container.AddExtension(MockUnit.Extension);
     var list = container.Resolve<IList>();
     Assert.IsFalse(list.Contains(string.Empty));
 }
开发者ID:stormleoxia,项目名称:lx,代码行数:7,代码来源:MockUnitStrategyTest.cs

示例3: Test

 public void Test()
 {
     var container = new UnityContainer();
     var settings = new Settings();
     container.AddExtension(new Bootstrapper(settings));
     container.Resolve<ProjectController>();
 }
开发者ID:iburgos,项目名称:net-igeo-service,代码行数:7,代码来源:BootstrappingTests.cs

示例4: Ext_ContainerCallsExtensionsInitializeMethod

        public void Ext_ContainerCallsExtensionsInitializeMethod()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer container = new UnityContainer();
            container.AddExtension(extension);

            Assert.IsTrue(extension.InitializeWasCalled);
        }
开发者ID:CFMITL,项目名称:unity,代码行数:8,代码来源:UnityExtension.cs

示例5: CheckExtensionAdded

        public void CheckExtensionAdded()
        {
            MyCustomExtension extension = new MyCustomExtension();
            IUnityContainer uc = new UnityContainer();
            uc.AddExtension(extension);

            Assert.IsTrue(extension.CheckExtensionValue);
        }
开发者ID:CFMITL,项目名称:unity,代码行数:8,代码来源:MyCustomExtensionFixture.cs

示例6: CheckExtensionAddedToContainer

        public void CheckExtensionAddedToContainer()
        {
            MyCustomExtension extension = new MyCustomExtension();
            IUnityContainer uc = new UnityContainer();
            uc.AddExtension(extension);

            Assert.AreSame(uc, extension.Container);
        }
开发者ID:CFMITL,项目名称:unity,代码行数:8,代码来源:MyCustomExtensionFixture.cs

示例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());
 }
开发者ID:stormleoxia,项目名称:lx,代码行数:9,代码来源:MockUnitStrategyTest.cs

示例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));
 }
开发者ID:stormleoxia,项目名称:lx,代码行数:9,代码来源:MockUnitStrategyTest.cs

示例9: Register

        public static IUnityContainer Register()
        {
            var container = new UnityContainer();

            // Register types in TextUtilModule
            container.AddExtension(new TextUtilModule());

            return container;
        }
开发者ID:krishna-per,项目名称:WordCounter,代码行数:9,代码来源:Unity.cs

示例10: AddExistingMyCustonExtensionToContainer

        public void AddExistingMyCustonExtensionToContainer()
        {
            MyCustomExtension extension = new MyCustomExtension();
            IUnityContainer uc = new UnityContainer();
            uc.AddExtension(extension);

            Assert.IsNotNull(uc);
            Assert.IsTrue(extension.CheckPolicyValue);
        }
开发者ID:CFMITL,项目名称:unity,代码行数:9,代码来源:MyCustomExtensionFixture.cs

示例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);
        }
开发者ID:CFMITL,项目名称:unity,代码行数:9,代码来源:UnityExtension.cs

示例12: CreateNewContainer

        public UnityContainerAdapter CreateNewContainer()
        {
            IUnityContainer container = new UnityContainer();
             foreach ( UnityContainerExtension extension in Extensions )
             {
            container.AddExtension( extension );
             }

             return new UnityContainerAdapter( container, InjectionMembers );
        }
开发者ID:gitter-badger,项目名称:Validation,代码行数:10,代码来源:UnityAdapterFactory.cs

示例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);
        }
开发者ID:dlidstrom,项目名称:EventStoreLite,代码行数:14,代码来源:UnityInstallerTest.cs

示例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);
        }
开发者ID:dlidstrom,项目名称:EventStoreLite,代码行数:14,代码来源:UnityInstallerTest.cs

示例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;
        }
开发者ID:ingledewjf,项目名称:WebApiPoC,代码行数:18,代码来源:UnityInstaller.cs


注:本文中的Microsoft.Practices.Unity.UnityContainer.AddExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。