partial void ResolveGenerated(ref object service, Type serviceType, object serviceKey, Type requiredServiceType, Request preRequestParent, object[] args) { if (serviceType == typeof(IocPerformance.Classes.Conditions.IExportConditionInterface)) { if ((serviceKey == null || DefaultKey.Of(1).Equals(serviceKey)) && requiredServiceType == null && Equals(preRequestParent, Request.Empty.Push(typeof(IocPerformance.Classes.Conditions.ImportConditionObject2), default(System.Type), (object)null, 68, FactoryType.Service, typeof(IocPerformance.Classes.Conditions.ImportConditionObject2), Reuse.Transient, RequestFlags.IsResolutionCall))) { service = GetDep0_IExportConditionInterface(this); } else if ((serviceKey == null || DefaultKey.Of(0).Equals(serviceKey)) && requiredServiceType == null && Equals(preRequestParent, Request.Empty.Push(typeof(IocPerformance.Classes.Conditions.ImportConditionObject1), default(System.Type), (object)null, 67, FactoryType.Service, typeof(IocPerformance.Classes.Conditions.ImportConditionObject1), Reuse.Transient, RequestFlags.IsResolutionCall))) { service = GetDep1_IExportConditionInterface(this); } else if ((serviceKey == null || DefaultKey.Of(2).Equals(serviceKey)) && requiredServiceType == null && Equals(preRequestParent, Request.Empty.Push(typeof(IocPerformance.Classes.Conditions.ImportConditionObject3), default(System.Type), (object)null, 69, FactoryType.Service, typeof(IocPerformance.Classes.Conditions.ImportConditionObject3), Reuse.Transient, RequestFlags.IsResolutionCall))) { service = GetDep2_IExportConditionInterface(this); } } }
public void Example() { var container = new Container(); container.Register <I, X>(); container.Register <I, Y>(); container.Register <I, Z>(serviceKey: "z"); // use an `object` key to get all of the registrations var items = container.Resolve <KeyValuePair <object, I>[]>(); // the keys of resolved items CollectionAssert.AreEqual( new object[] { DefaultKey.Of(0), DefaultKey.Of(1), "z" }, items.Select(x => x.Key)); // you may get only services with default keys var defaultItems = container.Resolve <KeyValuePair <DefaultKey, I>[]>(); Assert.AreEqual(2, defaultItems.Length); // or the one with string key var z = container.Resolve <KeyValuePair <string, I>[]>().Single().Value; Assert.IsInstanceOf <Z>(z); }
partial void ResolveGenerated(ref object service, Type serviceType, object serviceKey, Type requiredServiceType, Request preRequestParent, object[] args) { if (serviceType == typeof(Prism.Navigation.INavigationService)) { if (DefaultKey.Of(0).Equals(serviceKey)) { service = Get13_INavigationService(this); } else if ("PageNavigationService".Equals(serviceKey)) { service = Get14_INavigationService(this); } } else if (serviceType == typeof(object)) { if ("NavigationPage".Equals(serviceKey)) { service = Get17_Object(this); } else if ("SecondPage".Equals(serviceKey)) { service = Get18_Object(this); } else if ("MainPage".Equals(serviceKey)) { service = Get19_Object(this); } } }
public void Can_register_multiple_placeholders() { var c = new Container(); c.RegisterPlaceholder <IN>(); c.RegisterPlaceholder <IN>(); var arrFuncN = c.Resolve <Func <IN>[]>(); Assert.AreEqual(2, arrFuncN.Length); c.Register <IN, N1>(ifAlreadyRegistered: IfAlreadyRegistered.Replace, serviceKey: DefaultKey.Of(0)); c.Register <IN, N2>(ifAlreadyRegistered: IfAlreadyRegistered.Replace, serviceKey: DefaultKey.Of(1)); Assert.IsInstanceOf <N1>(arrFuncN[0]()); Assert.IsInstanceOf <N2>(arrFuncN[1]()); }
// typeof(MediatR.INotificationHandler<MediatR.Examples.Pinged>) internal static object Get19_INotificationHandler(IResolverContext r) { return(new MediatR.Examples.PingedAlsoHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.INotificationHandler <MediatR.Examples.Pinged>), default(System.Type), (object)DefaultKey.Of(1), 43, FactoryType.Service, typeof(MediatR.Examples.PingedAlsoHandler), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])))); }
// typeof(MediatR.IPipelineBehavior<MediatR.Examples.Jing, MediatR.Unit>) internal static object Get13_IPipelineBehavior(IResolverContext r) { return(new MediatR.Examples.GenericPipelineBehavior <MediatR.Examples.Jing, MediatR.Unit>((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior <MediatR.Examples.Jing, MediatR.Unit>), typeof(MediatR.IPipelineBehavior <,>), (object)DefaultKey.Of(2), 58, FactoryType.Service, typeof(MediatR.Examples.GenericPipelineBehavior <MediatR.Examples.Jing, MediatR.Unit>), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])))); }
// typeof(MediatR.IPipelineBehavior<MediatR.Examples.Jing, MediatR.Unit>) internal static object Get11_IPipelineBehavior(IResolverContext r) { return(new MediatR.Pipeline.RequestPreProcessorBehavior <MediatR.Examples.Jing, MediatR.Unit>(new MediatR.Pipeline.IRequestPreProcessor <MediatR.Examples.Jing>[] { new MediatR.Examples.GenericRequestPreProcessor <MediatR.Examples.Jing>((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior <MediatR.Examples.Jing, MediatR.Unit>), typeof(MediatR.IPipelineBehavior <,>), (object)DefaultKey.Of(1), 55, FactoryType.Service, typeof(MediatR.Pipeline.RequestPreProcessorBehavior <MediatR.Examples.Jing, MediatR.Unit>), Reuse.Transient, RequestFlags.IsResolutionCall).Push(typeof(System.Collections.Generic.IEnumerable <MediatR.Pipeline.IRequestPreProcessor <MediatR.Examples.Jing> >), default(System.Type), (object)null, 2, FactoryType.Wrapper, default(System.Type), Reuse.Transient, ((RequestFlags)0)).Push(typeof(MediatR.Pipeline.IRequestPreProcessor <MediatR.Examples.Jing>), default(System.Type), (object)DefaultKey.Of(0), IfUnresolved.ReturnDefaultIfNotRegistered, 56, FactoryType.Service, typeof(MediatR.Examples.GenericRequestPreProcessor <MediatR.Examples.Jing>), Reuse.Transient, ((RequestFlags)0), 0), default(object[]))) })); }
private IEnumerable <ResolveManyResult> ResolveManyGenerated(Type serviceType) { if (serviceType == typeof(MediatR.IRequestHandler <MediatR.Examples.Jing>)) { yield return(Of(Get0_IRequestHandler)); } if (serviceType == typeof(MediatR.IMediator)) { yield return(Of(Get1_IMediator)); } if (serviceType == typeof(MediatR.INotification)) { yield return(Of(Get2_INotification, DefaultKey.Of(0))); yield return(Of(Get3_INotification, DefaultKey.Of(1))); } if (serviceType == typeof(MediatR.IRequestHandler <MediatR.Examples.Ping, MediatR.Examples.Pong>)) { yield return(Of(Get4_IRequestHandler)); } if (serviceType == typeof(MediatR.IRequest <MediatR.Examples.Pong>)) { yield return(Of(Get5_IRequest)); } if (serviceType == typeof(MediatR.INotificationHandler <MediatR.Examples.Ponged>)) { yield return(Of(Get6_INotificationHandler)); yield return(Of(Get7_INotificationHandler)); // co-variant } if (serviceType == typeof(MediatR.INotificationHandler <MediatR.INotification>)) { yield return(Of(Get7_INotificationHandler)); } if (serviceType == typeof(MediatR.IPipelineBehavior <MediatR.Examples.Ping, MediatR.Examples.Pong>)) { yield return(Of(Get8_IPipelineBehavior, DefaultKey.Of(0), typeof(MediatR.IPipelineBehavior <,>))); yield return(Of(Get10_IPipelineBehavior, DefaultKey.Of(1), typeof(MediatR.IPipelineBehavior <,>))); yield return(Of(Get12_IPipelineBehavior, DefaultKey.Of(2), typeof(MediatR.IPipelineBehavior <,>))); } if (serviceType == typeof(MediatR.IPipelineBehavior <MediatR.Examples.Jing, MediatR.Unit>)) { yield return(Of(Get9_IPipelineBehavior, DefaultKey.Of(0), typeof(MediatR.IPipelineBehavior <,>))); yield return(Of(Get11_IPipelineBehavior, DefaultKey.Of(1), typeof(MediatR.IPipelineBehavior <,>))); yield return(Of(Get13_IPipelineBehavior, DefaultKey.Of(2), typeof(MediatR.IPipelineBehavior <,>))); } if (serviceType == typeof(MediatR.IBaseRequest)) { yield return(Of(Get14_IBaseRequest, DefaultKey.Of(0))); yield return(Of(Get15_IBaseRequest, DefaultKey.Of(1))); } if (serviceType == typeof(MediatR.INotificationHandler <MediatR.Examples.Pinged>)) { yield return(Of(Get16_INotificationHandler, typeof(MediatR.INotificationHandler <>))); yield return(Of(Get18_INotificationHandler, DefaultKey.Of(0))); yield return(Of(Get19_INotificationHandler, DefaultKey.Of(1))); yield return(Of(Get7_INotificationHandler)); // co-variant } if (serviceType == typeof(MediatR.IRequest)) { yield return(Of(Get17_IRequest)); } if (serviceType == typeof(MediatR.IRequest <MediatR.Unit>)) { yield return(Of(Get20_IRequest)); } }
partial void ResolveGenerated(ref object service, Type serviceType, object serviceKey, Type requiredServiceType, Request preRequestParent, object[] args) { if (serviceType == typeof(MediatR.INotification)) { if (DefaultKey.Of(0).Equals(serviceKey)) { service = Get2_INotification(this); } else if (DefaultKey.Of(1).Equals(serviceKey)) { service = Get3_INotification(this); } } else if (serviceType == typeof(MediatR.IPipelineBehavior <MediatR.Examples.Ping, MediatR.Examples.Pong>)) { if (DefaultKey.Of(0).Equals(serviceKey)) { service = Get8_IPipelineBehavior(this); } else if (DefaultKey.Of(1).Equals(serviceKey)) { service = Get10_IPipelineBehavior(this); } else if (DefaultKey.Of(2).Equals(serviceKey)) { service = Get12_IPipelineBehavior(this); } } else if (serviceType == typeof(MediatR.IPipelineBehavior <MediatR.Examples.Jing, MediatR.Unit>)) { if (DefaultKey.Of(0).Equals(serviceKey)) { service = Get9_IPipelineBehavior(this); } else if (DefaultKey.Of(1).Equals(serviceKey)) { service = Get11_IPipelineBehavior(this); } else if (DefaultKey.Of(2).Equals(serviceKey)) { service = Get13_IPipelineBehavior(this); } } else if (serviceType == typeof(MediatR.IBaseRequest)) { if (DefaultKey.Of(0).Equals(serviceKey)) { service = Get14_IBaseRequest(this); } else if (DefaultKey.Of(1).Equals(serviceKey)) { service = Get15_IBaseRequest(this); } } else if (serviceType == typeof(MediatR.INotificationHandler <MediatR.Examples.Pinged>)) { if (DefaultKey.Of(0).Equals(serviceKey)) { service = Get18_INotificationHandler(this); } else if (DefaultKey.Of(1).Equals(serviceKey)) { service = Get19_INotificationHandler(this); } } }
// typeof(MediatR.INotificationMediator<MediatR.Examples.Ponged>) internal static object Get1_INotificationMediator(IResolverContext r) { return(new MediatR.NotificationMediator <MediatR.Examples.Ponged>(new MediatR.INotificationHandler <MediatR.Examples.Ponged>[] { new MediatR.Examples.GenericHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.INotificationMediator <MediatR.Examples.Ponged>), typeof(MediatR.INotificationMediator <>), (object)null, 52, FactoryType.Service, typeof(MediatR.NotificationMediator <MediatR.Examples.Ponged>), Reuse.Transient, RequestFlags.IsResolutionCall).Push(typeof(System.Collections.Generic.IEnumerable <MediatR.INotificationHandler <MediatR.Examples.Ponged> >), default(System.Type), (object)null, 2, FactoryType.Wrapper, default(System.Type), Reuse.Transient, ((RequestFlags)0)).Push(typeof(MediatR.INotificationHandler <MediatR.Examples.Ponged>), typeof(MediatR.INotificationHandler <MediatR.INotification>), (object)null, IfUnresolved.ReturnDefaultIfNotRegistered, 34, FactoryType.Service, typeof(MediatR.Examples.GenericHandler), Reuse.Transient, ((RequestFlags)0), 0), default(object[]))), new MediatR.Examples.PongedHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.INotificationMediator <MediatR.Examples.Ponged>), typeof(MediatR.INotificationMediator <>), (object)null, 52, FactoryType.Service, typeof(MediatR.NotificationMediator <MediatR.Examples.Ponged>), Reuse.Transient, RequestFlags.IsResolutionCall).Push(typeof(System.Collections.Generic.IEnumerable <MediatR.INotificationHandler <MediatR.Examples.Ponged> >), default(System.Type), (object)null, 2, FactoryType.Wrapper, default(System.Type), Reuse.Transient, ((RequestFlags)0)).Push(typeof(MediatR.INotificationHandler <MediatR.Examples.Ponged>), default(System.Type), (object)DefaultKey.Of(0), IfUnresolved.ReturnDefaultIfNotRegistered, 43, FactoryType.Service, typeof(MediatR.Examples.PongedHandler), Reuse.Transient, ((RequestFlags)0), 0), default(object[]))) })); }
// typeof(Prism.Navigation.INavigationService) internal static object Get13_INavigationService(IResolverContext r) { return(new Prism.Navigation.PageNavigationService((Prism.Ioc.IContainerExtension)r.Resolve(typeof(Prism.Ioc.IContainerExtension), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(Prism.Navigation.INavigationService), default(System.Type), DefaultKey.Of(0), 28, FactoryType.Service, typeof(Prism.Navigation.PageNavigationService), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])), new Prism.Common.ApplicationProvider(), new Prism.Behaviors.PageBehaviorFactory(), new Prism.Logging.EmptyLogger())); }
private IEnumerable <ResolveManyResult> ResolveManyGenerated(Type serviceType) { if (serviceType == typeof(Prism.AppModel.IApplicationStore)) { yield return(Of(Get0_IApplicationStore)); } if (serviceType == typeof(PrismZero.Services.Hello.IHelloService)) { yield return(Of(Get1_IHelloService)); } if (serviceType == typeof(Prism.Services.IPageDialogService)) { yield return(Of(Get2_IPageDialogService)); } if (serviceType == typeof(Prism.Modularity.IModuleInitializer)) { yield return(Of(Get3_IModuleInitializer)); } if (serviceType == typeof(Prism.Events.IEventAggregator)) { yield return(Of(Get4_IEventAggregator)); } if (serviceType == typeof(Prism.Modularity.IModuleCatalog)) { yield return(Of(Get5_IModuleCatalog)); } if (serviceType == typeof(Prism.Services.IDeviceService)) { yield return(Of(Get6_IDeviceService)); } if (serviceType == typeof(Prism.Behaviors.IPageBehaviorFactory)) { yield return(Of(Get7_IPageBehaviorFactory)); } if (serviceType == typeof(PrismZero.ViewModels.MainPageViewModel)) { yield return(Of(Get8_MainPageViewModel)); } if (serviceType == typeof(Prism.Modularity.IModuleManager)) { yield return(Of(Get9_IModuleManager)); } if (serviceType == typeof(Prism.Services.Dialogs.IDialogService)) { yield return(Of(Get10_IDialogService)); } if (serviceType == typeof(Prism.Common.IApplicationProvider)) { yield return(Of(Get11_IApplicationProvider)); } if (serviceType == typeof(PrismZero.ViewModels.SecondPageViewModel)) { yield return(Of(Get12_SecondPageViewModel)); } if (serviceType == typeof(Prism.Navigation.INavigationService)) { yield return(Of(Get13_INavigationService, DefaultKey.Of(0))); yield return(Of(Get14_INavigationService, "PageNavigationService")); } if (serviceType == typeof(PrismZero.Views.MainPage)) { yield return(Of(Get15_MainPage)); } if (serviceType == typeof(PrismZero.Views.SecondPage)) { yield return(Of(Get16_SecondPage)); } if (serviceType == typeof(object)) { yield return(Of(Get17_Object, "NavigationPage")); yield return(Of(Get18_Object, "SecondPage")); yield return(Of(Get19_Object, "MainPage")); } if (serviceType == typeof(Prism.Logging.ILoggerFacade)) { yield return(Of(Get20_ILoggerFacade)); } }