public static IEnumerable <IServiceDescriptor> DefaultServices() { var describer = new ServiceDescriber(); yield return(describer.Transient <IFakeService, FakeService>()); yield return(describer.Transient <IFakeMultipleService, FakeOneMultipleService>()); yield return(describer.Transient <IFakeMultipleService, FakeTwoMultipleService>()); yield return(describer.Transient <IFakeOuterService, FakeOuterService>()); yield return(describer.Instance <IFakeServiceInstance>(new FakeService() { Message = "Instance" })); yield return(describer.Scoped <IFakeScopedService, FakeService>()); yield return(describer.Singleton <IFakeSingletonService, FakeService>()); yield return(describer.Transient <IFakeFallbackService, FakeService>()); yield return(describer.Transient <IDependOnNonexistentService, DependOnNonexistentService>()); yield return(describer.Describe( typeof(IFakeOpenGenericService <string>), typeof(FakeService), lifecycle: LifecycleKind.Transient)); yield return(describer.Describe( typeof(IFakeOpenGenericService <>), typeof(FakeOpenGenericService <>), lifecycle: LifecycleKind.Transient)); yield return(describer.Transient <IFactoryService>(provider => { var fakeService = provider.GetService <IFakeService>(); return new TransientFactoryService { FakeService = fakeService, Value = 42 }; })); yield return(describer.Scoped <ScopedFactoryService>(provider => { var fakeService = provider.GetService <IFakeService>(); return new ScopedFactoryService { FakeService = fakeService, }; })); yield return(describer.Transient <ServiceAcceptingFactoryService, ServiceAcceptingFactoryService>()); }
public static IEnumerable <IServiceDescriptor> GetDefaultServices(IConfiguration configuration) { var describe = new ServiceDescriber(configuration); yield return(describe.Describe( typeof(IOptionsAccessor <>), typeof(OptionsAccessor <>), null, LifecycleKind.Singleton)); }
public IEnumerable<IServiceDescriptor> DefineServices() { var describer = new ServiceDescriber(); yield return describer.Singleton<ICall, CallOne>(); yield return describer.Scoped<ICall, CallTwo>(); yield return describer.Transient<ICall, CallThree>(); yield return describer.Transient<ITypeActivator, TypeActivator>(); yield return describer.Describe( typeof(IContextAccessor<>), typeof(ContextAccessor<>), implementationInstance: null, lifecycle: LifecycleKind.Scoped); }
public static IEnumerable <IServiceDescriptor> DefaultServices() { var describer = new ServiceDescriber(); yield return(describer.Transient <IFakeService, FakeService>()); yield return(describer.Transient <IFakeMultipleService, FakeOneMultipleService>()); yield return(describer.Transient <IFakeMultipleService, FakeTwoMultipleService>()); yield return(describer.Transient <IFakeOuterService, FakeOuterService>()); yield return(describer.Instance <IFakeServiceInstance>(new FakeService() { Message = "Instance" })); yield return(describer.Scoped <IFakeScopedService, FakeService>()); yield return(describer.Singleton <IFakeSingletonService, FakeService>()); yield return(describer.Transient <IFakeFallbackService, FakeService>()); yield return(describer.Transient <IDependOnNonexistentService, DependOnNonexistentService>()); yield return(describer.Describe( typeof(IFakeOpenGenericService <string>), typeof(FakeService), implementationInstance: null, lifecycle: LifecycleKind.Transient)); yield return(describer.Describe( typeof(IFakeOpenGenericService <>), typeof(FakeOpenGenericService <>), implementationInstance: null, lifecycle: LifecycleKind.Transient)); }
public static IEnumerable<IServiceDescriptor> DefaultServices() { var describer = new ServiceDescriber(); yield return describer.Transient<IFakeService, FakeService>(); yield return describer.Transient<IFakeMultipleService, FakeOneMultipleService>(); yield return describer.Transient<IFakeMultipleService, FakeTwoMultipleService>(); yield return describer.Transient<IFakeOuterService, FakeOuterService>(); yield return describer.Instance<IFakeServiceInstance>(new FakeService() { Message = "Instance" }); yield return describer.Scoped<IFakeScopedService, FakeService>(); yield return describer.Singleton<IFakeSingletonService, FakeService>(); yield return describer.Transient<IFakeFallbackService, FakeService>(); yield return describer.Transient<IDependOnNonexistentService, DependOnNonexistentService>(); yield return describer.Describe( typeof(IFakeOpenGenericService<string>), typeof(FakeService), implementationInstance: null, lifecycle: LifecycleKind.Transient); yield return describer.Describe( typeof(IFakeOpenGenericService<>), typeof(FakeOpenGenericService<>), implementationInstance: null, lifecycle: LifecycleKind.Transient); }
public IEnumerable <IServiceDescriptor> DefineServices() { var describer = new ServiceDescriber(); yield return(describer.Singleton <ICall, CallOne>()); yield return(describer.Scoped <ICall, CallTwo>()); yield return(describer.Transient <ICall, CallThree>()); yield return(describer.Transient <ITypeActivator, TypeActivator>()); yield return(describer.Describe( typeof(IContextAccessor <>), typeof(ContextAccessor <>), implementationInstance: null, lifecycle: LifecycleKind.Scoped)); }
public static IEnumerable <IServiceDescriptor> GetDefaultServices(IConfiguration configuration) { var describe = new ServiceDescriber(configuration); yield return(describe.Transient <IOptionsSetup <MvcOptions>, MvcOptionsSetup>()); yield return(describe.Transient <IControllerFactory, DefaultControllerFactory>()); yield return(describe.Singleton <IControllerActivator, DefaultControllerActivator>()); yield return(describe.Scoped <IActionSelector, DefaultActionSelector>()); yield return(describe.Transient <IActionInvokerFactory, ActionInvokerFactory>()); yield return(describe.Transient <IControllerAssemblyProvider, DefaultControllerAssemblyProvider>()); yield return(describe.Transient <IActionDiscoveryConventions, DefaultActionDiscoveryConventions>()); yield return(describe.Instance <IMvcRazorHost>(new MvcRazorHost(typeof(RazorPage).FullName))); yield return(describe.Transient <ICompilationService, RoslynCompilationService>()); yield return(describe.Singleton <IViewEngineProvider, DefaultViewEngineProvider>()); yield return(describe.Scoped <ICompositeViewEngine, CompositeViewEngine>()); yield return(describe.Singleton <IRazorCompilationService, RazorCompilationService>()); yield return(describe.Singleton <IViewStartProvider, ViewStartProvider>()); yield return(describe.Singleton <IRazorPageActivator, RazorPageActivator>()); // Virtual path view factory needs to stay scoped so views can get get scoped services. yield return(describe.Scoped <IRazorPageFactory, VirtualPathRazorPageFactory>()); yield return(describe.Singleton <IFileInfoCache, ExpiringFileInfoCache>()); yield return(describe.Transient <INestedProvider <ActionDescriptorProviderContext>, ReflectedActionDescriptorProvider>()); yield return(describe.Transient <INestedProvider <ActionInvokerProviderContext>, ReflectedActionInvokerProvider>()); yield return(describe.Singleton <IActionDescriptorsCollectionProvider, DefaultActionDescriptorsCollectionProvider>()); yield return(describe.Transient <IModelMetadataProvider, DataAnnotationsModelMetadataProvider>()); yield return(describe.Scoped <IActionBindingContextProvider, DefaultActionBindingContextProvider>()); yield return(describe.Transient <IInputFormatter, JsonInputFormatter>()); yield return(describe.Transient <IInputFormatter, XmlSerializerInputFormatter>()); yield return(describe.Transient <IInputFormatter, XmlDataContractSerializerInputFormatter>()); yield return(describe.Transient <IInputFormatterProvider, TempInputFormatterProvider>()); yield return(describe.Transient <IModelBinderProvider, DefaultModelBindersProvider>()); yield return(describe.Scoped <ICompositeModelBinder, CompositeModelBinder>()); yield return(describe.Transient <IValueProviderFactoryProvider, DefaultValueProviderFactoryProvider>()); yield return(describe.Scoped <ICompositeValueProviderFactory, CompositeValueProviderFactory>()); yield return(describe.Transient <IOutputFormattersProvider, DefaultOutputFormattersProvider>()); yield return(describe.Transient <INestedProvider <FilterProviderContext>, DefaultFilterProvider>()); yield return(describe.Transient <IModelValidatorProvider, DataAnnotationsModelValidatorProvider>()); yield return(describe.Transient <IModelValidatorProvider, DataMemberModelValidatorProvider>()); yield return(describe.Scoped <IUrlHelper, UrlHelper>()); yield return(describe.Transient <IViewComponentSelector, DefaultViewComponentSelector>()); yield return(describe.Transient <IViewComponentInvokerFactory, DefaultViewComponentInvokerFactory>()); yield return(describe.Transient <INestedProvider <ViewComponentInvokerProviderContext>, DefaultViewComponentInvokerProvider>()); yield return(describe.Transient <IViewComponentHelper, DefaultViewComponentHelper>()); yield return(describe.Transient <IAuthorizationService, DefaultAuthorizationService>()); yield return(describe.Singleton <IClaimUidExtractor, DefaultClaimUidExtractor>()); yield return(describe.Singleton <AntiForgery, AntiForgery>()); yield return(describe.Singleton <IAntiForgeryAdditionalDataProvider, DefaultAntiForgeryAdditionalDataProvider>()); yield return (describe.Describe( typeof(INestedProviderManager <>), typeof(NestedProviderManager <>), implementationInstance: null, lifecycle: LifecycleKind.Transient)); yield return (describe.Describe( typeof(INestedProviderManagerAsync <>), typeof(NestedProviderManagerAsync <>), implementationInstance: null, lifecycle: LifecycleKind.Transient)); yield return(describe.Transient <IHtmlHelper, HtmlHelper>()); yield return (describe.Describe( typeof(IHtmlHelper <>), typeof(HtmlHelper <>), implementationInstance: null, lifecycle: LifecycleKind.Transient)); }
public static IEnumerable<IServiceDescriptor> GetDefaultServices(IConfiguration configuration) { var describe = new ServiceDescriber(configuration); yield return describe.Transient<IOptionsSetup<MvcOptions>, MvcOptionsSetup>(); yield return describe.Transient<IControllerFactory, DefaultControllerFactory>(); yield return describe.Singleton<IControllerActivator, DefaultControllerActivator>(); yield return describe.Scoped<IActionSelector, DefaultActionSelector>(); yield return describe.Transient<IActionInvokerFactory, ActionInvokerFactory>(); yield return describe.Transient<IControllerAssemblyProvider, DefaultControllerAssemblyProvider>(); yield return describe.Transient<IActionDiscoveryConventions, DefaultActionDiscoveryConventions>(); yield return describe.Instance<IMvcRazorHost>(new MvcRazorHost(typeof(RazorPage).FullName)); yield return describe.Transient<ICompilationService, RoslynCompilationService>(); yield return describe.Singleton<IViewEngineProvider, DefaultViewEngineProvider>(); yield return describe.Scoped<ICompositeViewEngine, CompositeViewEngine>(); yield return describe.Singleton<IRazorCompilationService, RazorCompilationService>(); yield return describe.Singleton<IViewStartProvider, ViewStartProvider>(); yield return describe.Singleton<IRazorPageActivator, RazorPageActivator>(); // Virtual path view factory needs to stay scoped so views can get get scoped services. yield return describe.Scoped<IRazorPageFactory, VirtualPathRazorPageFactory>(); yield return describe.Singleton<IFileInfoCache, ExpiringFileInfoCache>(); yield return describe.Transient<INestedProvider<ActionDescriptorProviderContext>, ReflectedActionDescriptorProvider>(); yield return describe.Transient<INestedProvider<ActionInvokerProviderContext>, ReflectedActionInvokerProvider>(); yield return describe.Singleton<IActionDescriptorsCollectionProvider, DefaultActionDescriptorsCollectionProvider>(); yield return describe.Transient<IModelMetadataProvider, DataAnnotationsModelMetadataProvider>(); yield return describe.Scoped<IActionBindingContextProvider, DefaultActionBindingContextProvider>(); yield return describe.Transient<IInputFormatter, JsonInputFormatter>(); yield return describe.Transient<IInputFormatter, XmlSerializerInputFormatter>(); yield return describe.Transient<IInputFormatter, XmlDataContractSerializerInputFormatter>(); yield return describe.Transient<IInputFormatterProvider, TempInputFormatterProvider>(); yield return describe.Transient<IModelBinderProvider, DefaultModelBindersProvider>(); yield return describe.Scoped<ICompositeModelBinder, CompositeModelBinder>(); yield return describe.Transient<IValueProviderFactoryProvider, DefaultValueProviderFactoryProvider>(); yield return describe.Scoped<ICompositeValueProviderFactory, CompositeValueProviderFactory>(); yield return describe.Transient<IOutputFormattersProvider, DefaultOutputFormattersProvider>(); yield return describe.Transient<INestedProvider<FilterProviderContext>, DefaultFilterProvider>(); yield return describe.Transient<IModelValidatorProvider, DataAnnotationsModelValidatorProvider>(); yield return describe.Transient<IModelValidatorProvider, DataMemberModelValidatorProvider>(); yield return describe.Scoped<IUrlHelper, UrlHelper>(); yield return describe.Transient<IViewComponentSelector, DefaultViewComponentSelector>(); yield return describe.Transient<IViewComponentInvokerFactory, DefaultViewComponentInvokerFactory>(); yield return describe.Transient<INestedProvider<ViewComponentInvokerProviderContext>, DefaultViewComponentInvokerProvider>(); yield return describe.Transient<IViewComponentHelper, DefaultViewComponentHelper>(); yield return describe.Transient<IAuthorizationService, DefaultAuthorizationService>(); yield return describe.Singleton<IClaimUidExtractor, DefaultClaimUidExtractor>(); yield return describe.Singleton<AntiForgery, AntiForgery>(); yield return describe.Singleton<IAntiForgeryAdditionalDataProvider, DefaultAntiForgeryAdditionalDataProvider>(); yield return describe.Describe( typeof(INestedProviderManager<>), typeof(NestedProviderManager<>), implementationInstance: null, lifecycle: LifecycleKind.Transient); yield return describe.Describe( typeof(INestedProviderManagerAsync<>), typeof(NestedProviderManagerAsync<>), implementationInstance: null, lifecycle: LifecycleKind.Transient); yield return describe.Transient<IHtmlHelper, HtmlHelper>(); yield return describe.Describe( typeof(IHtmlHelper<>), typeof(HtmlHelper<>), implementationInstance: null, lifecycle: LifecycleKind.Transient); }
public static IEnumerable <IServiceDescriptor> GetDefaultServices(IConfiguration configuration) { var describe = new ServiceDescriber(configuration); yield return(describe.Transient <IOptionsSetup <MvcOptions>, MvcOptionsSetup>()); yield return(describe.Transient <IControllerFactory, DefaultControllerFactory>()); yield return(describe.Singleton <IControllerActivator, DefaultControllerActivator>()); yield return(describe.Singleton <IActionSelectorDecisionTreeProvider, ActionSelectorDecisionTreeProvider>()); yield return(describe.Scoped <IActionSelector, DefaultActionSelector>()); yield return(describe.Transient <IActionInvokerFactory, ActionInvokerFactory>()); yield return(describe.Transient <IControllerAssemblyProvider, DefaultControllerAssemblyProvider>()); yield return(describe.Transient <IActionDiscoveryConventions, DefaultActionDiscoveryConventions>()); // The host is designed to be discarded after consumption and is very inexpensive to initialize. yield return(describe.Transient <IMvcRazorHost, MvcRazorHost>()); yield return(describe.Singleton <ICompilationService, RoslynCompilationService>()); yield return(describe.Singleton <IRazorCompilationService, RazorCompilationService>()); yield return(describe.Singleton <IViewEngineProvider, DefaultViewEngineProvider>()); yield return(describe.Scoped <ICompositeViewEngine, CompositeViewEngine>()); yield return(describe.Singleton <IViewStartProvider, ViewStartProvider>()); yield return(describe.Transient <IRazorView, RazorView>()); yield return(describe.Singleton <IRazorPageActivator, RazorPageActivator>()); // Virtual path view factory needs to stay scoped so views can get get scoped services. yield return(describe.Scoped <IRazorPageFactory, VirtualPathRazorPageFactory>()); yield return(describe.Singleton <IFileInfoCache, ExpiringFileInfoCache>()); yield return(describe.Transient <INestedProvider <ActionDescriptorProviderContext>, ReflectedActionDescriptorProvider>()); yield return(describe.Transient <INestedProvider <ActionInvokerProviderContext>, ReflectedActionInvokerProvider>()); yield return(describe.Singleton <IActionDescriptorsCollectionProvider, DefaultActionDescriptorsCollectionProvider>()); yield return(describe.Transient <IModelMetadataProvider, DataAnnotationsModelMetadataProvider>()); yield return(describe.Scoped <IActionBindingContextProvider, DefaultActionBindingContextProvider>()); yield return(describe.Transient <IInputFormatterSelector, DefaultInputFormatterSelector>()); yield return(describe.Scoped <IInputFormattersProvider, DefaultInputFormattersProvider>()); yield return(describe.Transient <IModelBinderProvider, DefaultModelBindersProvider>()); yield return(describe.Scoped <ICompositeModelBinder, CompositeModelBinder>()); yield return(describe.Transient <IValueProviderFactoryProvider, DefaultValueProviderFactoryProvider>()); yield return(describe.Scoped <ICompositeValueProviderFactory, CompositeValueProviderFactory>()); yield return(describe.Transient <IOutputFormattersProvider, DefaultOutputFormattersProvider>()); yield return(describe.Instance <JsonOutputFormatter>( new JsonOutputFormatter(JsonOutputFormatter.CreateDefaultSettings(), indent: false))); // The IGlobalFilterProvider is used to build the action descriptors (likely once) and so should // remain transient to avoid keeping it in memory. yield return(describe.Transient <IGlobalFilterProvider, DefaultGlobalFilterProvider>()); yield return(describe.Transient <INestedProvider <FilterProviderContext>, DefaultFilterProvider>()); yield return(describe.Transient <IModelValidatorProviderProvider, DefaultModelValidatorProviderProvider>()); yield return(describe.Scoped <ICompositeModelValidatorProvider, CompositeModelValidatorProvider>()); yield return(describe.Scoped <IUrlHelper, UrlHelper>()); yield return(describe.Transient <IViewComponentSelector, DefaultViewComponentSelector>()); yield return(describe.Singleton <IViewComponentActivator, DefaultViewComponentActivator>()); yield return(describe.Transient <IViewComponentInvokerFactory, DefaultViewComponentInvokerFactory>()); yield return(describe.Transient <INestedProvider <ViewComponentInvokerProviderContext>, DefaultViewComponentInvokerProvider>()); yield return(describe.Transient <IViewComponentHelper, DefaultViewComponentHelper>()); yield return(describe.Transient <IAuthorizationService, DefaultAuthorizationService>()); yield return(describe.Singleton <IClaimUidExtractor, DefaultClaimUidExtractor>()); yield return(describe.Singleton <AntiForgery, AntiForgery>()); yield return(describe.Singleton <IAntiForgeryAdditionalDataProvider, DefaultAntiForgeryAdditionalDataProvider>()); yield return (describe.Describe( typeof(INestedProviderManager <>), typeof(NestedProviderManager <>), implementationInstance: null, lifecycle: LifecycleKind.Transient)); yield return (describe.Describe( typeof(INestedProviderManagerAsync <>), typeof(NestedProviderManagerAsync <>), implementationInstance: null, lifecycle: LifecycleKind.Transient)); yield return(describe.Transient <IHtmlHelper, HtmlHelper>()); yield return (describe.Describe( typeof(IHtmlHelper <>), typeof(HtmlHelper <>), implementationInstance: null, lifecycle: LifecycleKind.Transient)); yield return(describe.Transient <MvcMarkerService, MvcMarkerService>()); }