Пример #1
0
        private static void Register(ServiceRegistrator registrator, Action <Type, Type> registrationStub, RegisterMethod registerMethod)
        {
            switch (registerMethod)
            {
            case RegisterMethod.Singleton:
                registrator.RegisterSingletons(registrationStub);
                return;

            case RegisterMethod.Transient:
                registrator.RegisterTransient(registrationStub);
                return;

            default:
                throw new ArgumentOutOfRangeException("Not supported method!");
            }
        }
Пример #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            ApplicationConfigurationProvider.Instance.InitializeConfiguration(_configuration);
            services.AddSingleton(typeof(IApplicationConfiguration), ApplicationConfigurationProvider.Instance.Configuration);

            var typesProvider      = new DefaultTypesProvider();
            var serviceRegistrator = new ServiceRegistrator(typesProvider);

            serviceRegistrator.RegisterSingletons((toImplement, implementation) => services.AddSingleton(toImplement, implementation));
            serviceRegistrator.RegisterTransient((toImplement, implementation) => services.AddTransient(toImplement, implementation));

            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
        }