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


C# IUnityContainer.ResolveAll方法代码示例

本文整理汇总了C#中IUnityContainer.ResolveAll方法的典型用法代码示例。如果您正苦于以下问题:C# IUnityContainer.ResolveAll方法的具体用法?C# IUnityContainer.ResolveAll怎么用?C# IUnityContainer.ResolveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUnityContainer的用法示例。


在下文中一共展示了IUnityContainer.ResolveAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestFixtureSetup

        public void TestFixtureSetup()
        {
            _container = new UnityContainer()
                        .RegisterType<IDomainEvent, CustomerBecamePreferred>()
                        .RegisterType<IHandle<CustomerBecamePreferred>, CustomerBecamePreferredHandler>("CustomerBecamePreferredHandler")
                        .RegisterType<IHandle<CustomerBecamePreferred>, BillingWantsToKnowCustomerBecamePreferredHandler>("BillingWantsToKnowCustomerBecamePreferredHandler")
                        .RegisterType<IHandle<CustomerexceededAccountLimit>, CustomerExceededAccountLimitHandler>("CustomerExceededAccountLimitHandler")
                        .RegisterType<IHandle<CustomerexceededAccountLimit>, BillingWantsToKnowCustomerExceededAccountLimitHandler>("BillingWantsToKnowCustomerExceededAccountLimitHandler");

            DomainEvents.Container = _container;

            Assert.That(_container.ResolveAll<IHandle<CustomerBecamePreferred>>().Count(), Is.EqualTo(2));
            Assert.That(_container.ResolveAll<IHandle<CustomerexceededAccountLimit>>().Count(), Is.EqualTo(2));
        }
开发者ID:netify,项目名称:Employing-the-Domain-Model-Pattern,代码行数:14,代码来源:UnitTest.cs

示例2: Execute

        public void Execute(IUnityContainer unityContainer)
        {
            // setup components
            var components = unityContainer.ResolveAll<IIncludeComponents>();

            foreach (var component in components)
                component.Setup();

            // register dependencies
            var dependencies = unityContainer.ResolveAll<IRegisterDependency>();

            foreach (var dependency in dependencies)
                dependency.Inject(unityContainer);

            DependencyResolver.SetResolver(new UnityDependencyResolver(unityContainer));
        }
开发者ID:avijassra,项目名称:CodeLab,代码行数:16,代码来源:RegisterStartupTasks.cs

示例3: Configure

        public static void Configure(IUnityContainer container)
        {
            SecurityConfigurator.Configure(configuration =>
            {
                configuration.ResolveServicesUsing(type => container.ResolveAll(type));

                // Configuración real
                configuration.GetAuthenticationStatusFrom(() => HttpContext.Current.User.Identity.IsAuthenticated);
                configuration.GetRolesFrom(() => RoleHelper.GetRolesForUser(HttpContext.Current.User.Identity.Name));

                configuration.Advanced.SetDefaultResultsCacheLifecycle(Cache.PerHttpSession);

                // Configuración de las páginas de usuario
                configuration.For<CuentaController>(x => x.LogOn())
                    .Ignore();
                configuration.For<CuentaController>(x => x.LogOff())
                    .DenyAnonymousAccess();
                configuration.For<Controllers.InformeController>()
                    .DenyAnonymousAccess();
                configuration.For<SituacionController>()
                    .DenyAnonymousAccess();

                // Configuración de las páginas de administración
                configuration.ForAllControllersInNamespaceContainingType<BuscarController>()
                    .RequireAnyRole(Roles.Jefe);
            });

            GlobalFilters.Filters.Add(new HandleSecurityAttribute(), 0);
        }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:29,代码来源:SecurityConfig.cs

示例4: ApiManager

        public ApiManager(IUnityContainer container, IApiMethodInvoker invoker)
        {
            _container = container;
            _invoker = invoker;
            _paramInspectors = _container.ResolveAll<IApiParamInspector>().ToList();
            _methods = _container.Resolve<IEnumerable<IApiMethodCall>>();

        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:8,代码来源:ApiManager.cs

示例5: Start

        public static void Start(IUnityContainer container)
        {
            if (container == null) throw new ArgumentNullException(nameof(container));

            foreach (var processor in container.ResolveAll<IProcessor>())
            {
                HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => processor.Start(cancellationToken));
            }
        }
开发者ID:fvilers,项目名称:Darjeel,代码行数:9,代码来源:ProcessorConfig.cs

示例6: ApplyServiceBehaviors

        private void ApplyServiceBehaviors(IUnityContainer container)
        {
            var registeredServiceBehaviors = container.ResolveAll<IServiceBehavior>();

            foreach (var serviceBehavior in registeredServiceBehaviors)
            {
                Description.Behaviors.Add(serviceBehavior);
            }
        }
开发者ID:jackerdey,项目名称:unity-wcf,代码行数:9,代码来源:UnityServiceHost.cs

示例7: SerializerResponder

        public SerializerResponder(IUnityContainer container)
        {
            var serializers = container.ResolveAll<IApiSerializer>();
            if (serializers==null)
                throw new ArgumentException("No serializers resolved");

            _serializers = new List<IApiSerializer>(serializers);
            if (!_serializers.Any())
                throw new ArgumentException("No serializers defined");
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:10,代码来源:SerializerResponder.cs

示例8: Init

        public void Init(IUnityContainer container)
        {
            container.RegisterType<ITextSerializer, JsonSerializer>();
            var eventBus = new InMemoryEventBus();
            container.RegisterInstance<IEventBus>(eventBus);
            var commandBus = new InMemoryCommandBus();
            container.RegisterInstance<ICommandBus>(commandBus);

            container.RegisterType<IEventStore, SqlEventStore>();

            foreach (var handler in container.ResolveAll<ICommandHandler>())
            {
                commandBus.Register(handler);
            }

            foreach (var handler in container.ResolveAll<IEventHandler>())
            {
                eventBus.Register(handler);
            }
        }
开发者ID:Costo,项目名称:sketch,代码行数:20,代码来源:Module.cs

示例9: FinalConfiguration

        public void FinalConfiguration(IUnityContainer container)
        {
            var npcmanager = container.Resolve<EQEmu.Spawns.NpcPropertyTemplateManager>();
            npcmanager.Templates = container.ResolveAll<EQEmu.Spawns.INpcPropertyTemplate>();

            //register it just in case resolve created a new instance of the manager
            //as opposed to one being already registered with the container
            container.RegisterInstance(npcmanager);

            var vm = container.Resolve<NpcTypeEditViewModel>();
            container.RegisterInstance(vm);
        }
开发者ID:Unchated,项目名称:pogee-3d-editor,代码行数:12,代码来源:NpcTypeAppSetup.cs

示例10: ApplyContractBehaviors

        private void ApplyContractBehaviors(IUnityContainer container)
        {
            var registeredContractBehaviors = container.ResolveAll<IContractBehavior>();

            foreach (var contractBehavior in registeredContractBehaviors)
            {
                foreach (var contractDescription in ImplementedContracts.Values)
                {
                    contractDescription.Behaviors.Add(contractBehavior);
                }
            }
        }
开发者ID:jackerdey,项目名称:unity-wcf,代码行数:12,代码来源:UnityServiceHost.cs

示例11: RegisterTypes

        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
        /// <param name="container">The unity container to configure.</param>
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
			//RegisterWebApiResolver(container);
			PreConfig(container);
			ConfigureFromFile(container);
	        CrossConcern(container);
	        WebApiConfig(container);

			container.ResolveAll<IBootstrapper>().ForEach(x => x.Run());

			PosConfig(container);
        }
开发者ID:rock-walker,项目名称:Eline,代码行数:16,代码来源:UnityConfig.cs

示例12: Execute

        public override TaskContinuation Execute(IUnityContainer container)
        {
            Func<Type, bool> filter = type => KnownTypes.ValueProviderFactoryType.IsAssignableFrom(type) &&
                                                 !ValueProviderFactories.Any(factory => factory.GetType() == type);

            BuildManagerWrapper.Current.ConcreteTypes.Where(filter)
                     .Each(type => container.RegisterTypeAsSingleton(KnownTypes.ValueProviderFactoryType, type));

            container.ResolveAll<ValueProviderFactory>()
                     .Each(factory => ValueProviderFactories.Add(factory));

            return TaskContinuation.Continue;
        }
开发者ID:yhhno,项目名称:MvcInfrastructure,代码行数:13,代码来源:ValueProviderFactoryRegister.cs

示例13: Register

        public static void Register(IUnityContainer container, Guid containerGuid)
        {
            container.RegisterInstance(typeof(IControllerActivator), new UnityControllerActivator(containerGuid));

            foreach (var type in Assembly.GetExecutingAssembly().GetExportedTypes().
                            Where(x => x.GetInterface(typeof(IController).Name) != null))
            {
                container.RegisterType(type);
            }

            DependencyResolver.SetResolver(
                t => container.IsRegistered(t) ? container.Resolve(t) : null,
                t => container.IsRegistered(t) ? container.ResolveAll(t) : Enumerable.Empty<object>());
        }
开发者ID:moodswing,项目名称:ResyRoom,代码行数:14,代码来源:MvcConfig.cs

示例14: Init

        public static void Init(IUnityContainer container, List<TimingTask> taskList)
        {
            taskList.Clear();

            IEnumerable<MultiTask> comms = container.ResolveAll<MultiTask>();

            int count = 0;
            foreach (MultiTask comm in comms)
            {
                comm.LoadTask(taskList);
                count++;
            }

            if (count > 0)
            {
                TimingTaskManager taskmanager = new TimingTaskManager();
                taskmanager.TaskList = taskList;
                taskmanager.Initialize();
            }
        }
开发者ID:keep01,项目名称:efwplus_winformframe,代码行数:20,代码来源:MultiTask.cs

示例15: WriterCollection

 private static object WriterCollection(IUnityContainer container)
 {
     return container.ResolveAll<IReportWriter>().ToList();
 }
开发者ID:AlphaStaxLLC,项目名称:dotnet-apiport,代码行数:4,代码来源:DependencyBuilder.cs


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