本文整理汇总了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));
}
示例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));
}
示例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);
}
示例4: ApiManager
public ApiManager(IUnityContainer container, IApiMethodInvoker invoker)
{
_container = container;
_invoker = invoker;
_paramInspectors = _container.ResolveAll<IApiParamInspector>().ToList();
_methods = _container.Resolve<IEnumerable<IApiMethodCall>>();
}
示例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));
}
}
示例6: ApplyServiceBehaviors
private void ApplyServiceBehaviors(IUnityContainer container)
{
var registeredServiceBehaviors = container.ResolveAll<IServiceBehavior>();
foreach (var serviceBehavior in registeredServiceBehaviors)
{
Description.Behaviors.Add(serviceBehavior);
}
}
示例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");
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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>());
}
示例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();
}
}
示例15: WriterCollection
private static object WriterCollection(IUnityContainer container)
{
return container.ResolveAll<IReportWriter>().ToList();
}