Пример #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            // works with VCAP_SERVICES JSON value added to vcap-local.json when running locally,
            // and works with actual VCAP_SERVICES env var based on configuration set above when running in CF
            var creds = new CloudantDotNet.Models.Creds()
            {
                username = Configuration["cloudantNoSQLDB:0:credentials:username"],
                password = Configuration["cloudantNoSQLDB:0:credentials:password"],
                host     = Configuration["cloudantNoSQLDB:0:credentials:host"]
            };

            services.AddSingleton(typeof(CloudantDotNet.Models.Creds), creds);
            services.AddTransient <ICloudantService, CloudantService>();
        }
Пример #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll",
                                  p => p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());
            });
            services.AddMvc();

            // works with VCAP_SERVICES JSON value added to vcap-local.json when running locally,
            // and works with actual VCAP_SERVICES env var based on configuration set above when running in CF
            var creds = new CloudantDotNet.Models.Creds()
            {
                username = Configuration["cloudantNoSQLDB:0:credentials:username"],
                password = Configuration["cloudantNoSQLDB:0:credentials:password"],
                host     = Configuration["cloudantNoSQLDB:0:credentials:host"]
            };

            services.AddSingleton(typeof(CloudantDotNet.Models.Creds), creds);
            services.AddTransient <IForexEntryRepository, ForexEntryRepository>();
        }