public static IEnumerable <IServiceDescriptor> GetDefaultServices(IConfiguration configuration) { var serviceDescriber = new ServiceDescriber(configuration); // REVIEW: All singletons can't be right but we're just doing this because // we had this before yield return(serviceDescriber.Singleton <IMessageBus, MessageBus>()); yield return(serviceDescriber.Singleton <IMemoryPool, MemoryPool>()); yield return(serviceDescriber.Singleton <IStringMinifier, StringMinifier>()); yield return(serviceDescriber.Singleton <ITransportManager, TransportManager>()); yield return(serviceDescriber.Singleton <ITransportHeartbeat, TransportHeartbeat>()); yield return(serviceDescriber.Singleton <IConnectionManager, ConnectionManager>()); yield return(serviceDescriber.Singleton <IAckHandler, AckHandler>()); yield return(serviceDescriber.Singleton <IAssemblyLocator, DefaultAssemblyLocator>()); yield return(serviceDescriber.Singleton <IHubManager, DefaultHubManager>()); yield return(serviceDescriber.Singleton <IMethodDescriptorProvider, ReflectedMethodDescriptorProvider>()); yield return(serviceDescriber.Singleton <IHubDescriptorProvider, ReflectedHubDescriptorProvider>()); yield return(serviceDescriber.Singleton <IPerformanceCounterManager, PerformanceCounterManager>()); yield return(serviceDescriber.Singleton <JsonSerializer, JsonSerializer>()); yield return(serviceDescriber.Singleton <IUserIdProvider, PrincipalUserIdProvider>()); yield return(serviceDescriber.Singleton <IParameterResolver, DefaultParameterResolver>()); yield return(serviceDescriber.Singleton <IHubActivator, DefaultHubActivator>()); yield return(serviceDescriber.Singleton <IJavaScriptProxyGenerator, DefaultJavaScriptProxyGenerator>()); yield return(serviceDescriber.Singleton <IJavaScriptMinifier, NullJavaScriptMinifier>()); yield return(serviceDescriber.Singleton <IHubRequestParser, HubRequestParser>()); // REVIEW: This used to be lazy var pipeline = new HubPipeline(); pipeline.AddModule(new AuthorizeModule()); yield return(serviceDescriber.Instance <IHubPipeline>(pipeline)); yield return(serviceDescriber.Instance <IHubPipelineInvoker>(pipeline)); // TODO: Just use the new IDataProtectionProvider abstraction directly here yield return(serviceDescriber.Singleton <IProtectedData, DataProtectionProviderProtectedData>()); }
public static IEnumerable <IServiceDescriptor> GetDefaultRoleServices <TRole>(IConfiguration configuration) where TRole : class { var describe = new ServiceDescriber(configuration); yield return(describe.Instance <IRoleValidator <TRole> >(new RoleValidator <TRole>())); }
public static IEnumerable <IServiceDescriptor> GetDefaultServices(IConfiguration configuration) { var describer = new ServiceDescriber(configuration); yield return(describer.Transient <IHostingEngine, HostingEngine>()); yield return(describer.Transient <IServerManager, ServerManager>()); yield return(describer.Transient <IStartupManager, StartupManager>()); yield return(describer.Transient <IStartupLoaderProvider, StartupLoaderProvider>()); yield return(describer.Transient <IApplicationBuilderFactory, ApplicationBuilderFactory>()); yield return(describer.Transient <IHttpContextFactory, HttpContextFactory>()); yield return(describer.Singleton <ITypeActivator, TypeActivator>()); yield return(describer.Instance <IApplicationLifetime>(new ApplicationLifetime())); // TODO: Do we expect this to be provide by the runtime eventually? yield return(describer.Singleton <ILoggerFactory, LoggerFactory>()); yield return(describer.Scoped(typeof(IContextAccessor <>), typeof(ContextAccessor <>))); foreach (var service in OptionsServices.GetDefaultServices()) { yield return(service); } foreach (var service in DataProtectionServices.GetDefaultServices()) { yield return(service); } }
public static IEnumerable <IServiceDescriptor> GetDefaultServices(IConfiguration configuration) { var describer = new ServiceDescriber(configuration); yield return(describer.Transient <IHostingEngine, HostingEngine>()); yield return(describer.Transient <IServerManager, ServerManager>()); yield return(describer.Transient <IStartupManager, StartupManager>()); yield return(describer.Transient <IStartupLoaderProvider, StartupLoaderProvider>()); yield return(describer.Transient <IBuilderFactory, BuilderFactory>()); yield return(describer.Transient <IHttpContextFactory, HttpContextFactory>()); yield return(describer.Transient <ITypeActivator, TypeActivator>()); yield return(describer.Instance <IApplicationLifetime>(new ApplicationLifetime())); // TODO: We expect this to be provide by the runtime eventually. yield return(describer.Instance <ILoggerFactory>(new NullLoggerFactory())); yield return(new ServiceDescriptor { ServiceType = typeof(IContextAccessor <>), ImplementationType = typeof(ContextAccessor <>), Lifecycle = LifecycleKind.Scoped }); if (PlatformHelper.IsMono) { #if NET45 yield return(describer.Instance <IDataProtectionProvider>(DataProtectionProvider.CreateFromLegacyDpapi())); #endif } else { // The default IDataProtectionProvider is a singleton. // Note: DPAPI isn't usable in IIS where the user profile hasn't been loaded, but loading DPAPI // is deferred until the first call to Protect / Unprotect. It's up to an IIS-based host to // replace this service as part of application initialization. yield return(describer.Instance <IDataProtectionProvider>(DataProtectionProvider.CreateFromDpapi())); } }
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>()); }
/// <summary> /// 获取蓝图中的依赖项和事件。 /// </summary> private Tuple <IEnumerable <SmartServiceDescriptor>, IEnumerable <EventSubscriptionDescriptor> > BuildDependencies(ShellBlueprint blueprint) { List <SmartServiceDescriptor> smartServiceDescriptors = new List <SmartServiceDescriptor>(); smartServiceDescriptors.Add(ServiceDescriber.Instance(blueprint, SmartOptions.Replace)); smartServiceDescriptors.Add(ServiceDescriber.Instance(blueprint.Descriptor, SmartOptions.Replace)); SetupServiceDescriptors(blueprint, smartServiceDescriptors); List <EventSubscriptionDescriptor> eventSubs = new List <EventSubscriptionDescriptor>(); SetupDependencies(blueprint, smartServiceDescriptors, eventSubs); return(new Tuple <IEnumerable <SmartServiceDescriptor>, IEnumerable <EventSubscriptionDescriptor> >(smartServiceDescriptors, eventSubs)); }
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 static IEnumerable <IServiceDescriptor> GetDefaultServices(IConfiguration configuration = null) { var describe = new ServiceDescriber(configuration); // // Options and core services. // yield return(describe.Transient <IConfigureOptions <MvcOptions>, MvcOptionsSetup>()); yield return(describe.Transient <IConfigureOptions <RazorViewEngineOptions>, RazorViewEngineOptionsSetup>()); yield return(describe.Transient <IAssemblyProvider, DefaultAssemblyProvider>()); yield return(describe.Transient(typeof(INestedProviderManager <>), typeof(NestedProviderManager <>))); yield return(describe.Transient(typeof(INestedProviderManagerAsync <>), typeof(NestedProviderManagerAsync <>))); yield return(describe.Transient <MvcMarkerService, MvcMarkerService>()); // // Core action discovery, filters and action execution. // // These are consumed only when creating action descriptors, then they can be de-allocated yield return(describe.Transient <IControllerModelBuilder, DefaultControllerModelBuilder>()); yield return(describe.Transient <IActionModelBuilder, DefaultActionModelBuilder>()); // This accesses per-request services to activate the controller yield return(describe.Transient <IControllerFactory, DefaultControllerFactory>()); // This has a cache, so it needs to be a singleton yield return(describe.Singleton <IControllerActivator, DefaultControllerActivator>()); // This accesses per-reqest services yield return(describe.Transient <IActionInvokerFactory, ActionInvokerFactory>()); // This provider needs access to the per-request services, but might be used many times for a given // request. yield return(describe.Scoped <INestedProvider <ActionConstraintProviderContext>, DefaultActionConstraintProvider>()); yield return(describe.Singleton <IActionSelectorDecisionTreeProvider, ActionSelectorDecisionTreeProvider>()); yield return(describe.Scoped <IActionSelector, DefaultActionSelector>()); yield return(describe.Transient <IControllerActionArgumentBinder, DefaultControllerActionArgumentBinder>()); yield return(describe.Transient <INestedProvider <ActionDescriptorProviderContext>, ControllerActionDescriptorProvider>()); yield return(describe.Transient <INestedProvider <ActionInvokerProviderContext>, ControllerActionInvokerProvider>()); yield return(describe.Singleton <IActionDescriptorsCollectionProvider, DefaultActionDescriptorsCollectionProvider>()); // 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>()); // // Dataflow - ModelBinding, Validation and Formatting // 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())); yield return(describe.Transient <IModelValidatorProviderProvider, DefaultModelValidatorProviderProvider>()); yield return(describe.Scoped <ICompositeModelValidatorProvider, CompositeModelValidatorProvider>()); yield return(describe.Transient <IBodyModelValidator, DefaultBodyModelValidator>()); yield return(describe.Transient <IValidationExcludeFiltersProvider, DefaultValidationExcludeFiltersProvider>()); // // Razor, Views and runtime compilation // // The provider is inexpensive to initialize and provides ViewEngines that may require request // specific services. yield return(describe.Scoped <ICompositeViewEngine, CompositeViewEngine>()); yield return(describe.Transient <IViewEngineProvider, DefaultViewEngineProvider>()); // Transient since the IViewLocationExpanders returned by the instance is cached by view engines. yield return(describe.Transient <IViewLocationExpanderProvider, DefaultViewLocationExpanderProvider>()); // Caches view locations that are valid for the lifetime of the application. yield return(describe.Singleton <IViewLocationCache, DefaultViewLocationCache>()); yield return(describe.Singleton <IRazorFileSystemCache, DefaultRazorFileSystemCache>()); // The host is designed to be discarded after consumption and is very inexpensive to initialize. yield return(describe.Transient <IMvcRazorHost>(serviceProvider => { var cachedFileSystem = serviceProvider.GetRequiredService <IRazorFileSystemCache>(); return new MvcRazorHost(cachedFileSystem); })); // Caches compilation artifacts across the lifetime of the application. yield return(describe.Singleton <ICompilerCache, CompilerCache>()); // This caches compilation related details that are valid across the lifetime of the application // and is required to be a singleton. yield return(describe.Singleton <ICompilationService, RoslynCompilationService>()); // Both the compiler cache and roslyn compilation service hold on the compilation related // caches. RazorCompilation service is just an adapter service, and it is transient to ensure // the IMvcRazorHost dependency does not maintain state. yield return(describe.Transient <IRazorCompilationService, RazorCompilationService>()); // The ViewStartProvider needs to be able to consume scoped instances of IRazorPageFactory yield return(describe.Scoped <IViewStartProvider, ViewStartProvider>()); yield return(describe.Transient <IRazorViewFactory, RazorViewFactory>()); 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>()); // // View and rendering helpers // yield return(describe.Transient <IHtmlHelper, HtmlHelper>()); yield return(describe.Transient(typeof(IHtmlHelper <>), typeof(HtmlHelper <>))); yield return(describe.Scoped <IUrlHelper, UrlHelper>()); // Only want one ITagHelperActivator so it can cache Type activation information. Types won't conflict. yield return(describe.Singleton <ITagHelperActivator, DefaultTagHelperActivator>()); // DefaultHtmlGenerator is pretty much stateless but depends on Scoped services such as IUrlHelper and // IActionBindingContextProvider. Therefore it too is scoped. yield return(describe.Transient <IHtmlGenerator, DefaultHtmlGenerator>()); 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>()); // // Security and Authorization // yield return(describe.Transient <IAuthorizationService, DefaultAuthorizationService>()); yield return(describe.Singleton <IClaimUidExtractor, DefaultClaimUidExtractor>()); yield return(describe.Singleton <AntiForgery, AntiForgery>()); yield return(describe.Singleton <IAntiForgeryAdditionalDataProvider, DefaultAntiForgeryAdditionalDataProvider>()); // // Api Description // yield return(describe.Singleton <IApiDescriptionGroupCollectionProvider, ApiDescriptionGroupCollectionProvider>()); yield return(describe.Transient <INestedProvider <ApiDescriptionProviderContext>, DefaultApiDescriptionProvider>()); }
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>()); }