Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // needed to load IP Rate limit configuration from appsettings.json
            services.AddOptions();

            var configuration = StartupConfiguration.Configure(Container, services);

            // needed to store IP rate limit counters and ip rules, as well as in-memory API caching
            services.AddMemoryCache();

            services.AddControllersWithViews();

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            StartupConfiguration.ConfigureIoC(Container, services);
            StartupConfiguration.ConfigureLogging(Container, services);
            var provider = Container.CreateServiceProvider(services);

            Container.ScopeManagerProvider = new PerLogicalCallContextScopeManagerProvider();
            Container.BeginScope();

            return(provider);
        }
Пример #2
0
        /// <summary>
        /// Creating a service provider is required purely for use by the KMSHostService.
        /// Any web services it launches will be responsible for initializing their own provider
        /// </summary>
        /// <param name="container"></param>
        /// <returns></returns>
        static IServiceProvider ConfigureServices(IServiceContainer container)
        {
            var services = new ServiceCollection();

            StartupConfiguration.Configure(container, services);
            StartupConfiguration.ConfigureIoC(container, services);
            StartupConfiguration.ConfigureLogging(container, services);
            var provider = container.CreateServiceProvider(services);

            container.RegisterInstance(provider);
            StartupConfiguration.LoadNLogConfiguration(container, provider, LogManagerConfigFile);

            container.ScopeManagerProvider = new PerLogicalCallContextScopeManagerProvider();
            container.BeginScope();

            return(provider);
        }