Beispiel #1
0
 public static void ConfigureServices(ServiceCollection services)
 {
     services.AddLogging();
     services.AddOptions();
     //			services.Configure<FBoxClientParameters>(_configuration.GetSection("FBox"));
     services.AddTransient <FBoxDemo>();
 }
Beispiel #2
0
        public static IAuthorizationService BuildAuthorizationService(Action <IServiceCollection> setupServices = null)
        {
            var services = new Microsoft.Extensions.DependencyInjection.ServiceCollection();

            services.AddAuthorization();
            services.AddOptions();
            services.AddLogging();
            setupServices?.Invoke(services);
            return(services.BuildServiceProvider().GetRequiredService <IAuthorizationService>());
        }
        private static IServiceCollection CreateServices()
        {
            var services = new Microsoft.Extensions.DependencyInjection.ServiceCollection();

            services.AddOptions();
            services.AddLogging((builder) => {
                builder.AddConsole();
            });
            services.AddHttpClientGenerator((configure) => {
                configure.AddConfiguration("github", (httpClientConfiguration) => {
                    httpClientConfiguration.BaseAddress = "https://www.github.com";
                });
            });
            return(services);
        }
        private static IServiceProvider InitIoc()
        {
            var Services = new Microsoft.Extensions.DependencyInjection.ServiceCollection();
            var builder  = new ConfigurationBuilder()
                           .SetBasePath(Directory.GetCurrentDirectory())
                           .AddJsonFile("appsettings.json");

            var Configuration = builder.Build();

            ContainerIoC.Register(Services);

            Services.AddOptions();
            Services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));


            return(Services.BuildServiceProvider());
        }
Beispiel #5
0
        protected void Application_Start(object sender, EventArgs e)
        {
            //
            // Setup configuration
            IConfiguration configuration = new ConfigurationBuilder()
                                           .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                                           .Build();

            //
            // Setup application services + feature management
            IServiceCollection services = new ServiceCollection();

            services.AddSingleton(configuration)
            .AddFeatureManagement();
            services.AddOptions <BCLAppConfig>()
            .Bind(configuration.GetSection("BCLAppConfig"));
            services.AddSingleton <BCLApp>();

            _serviceProvider = services.BuildServiceProvider();
        }