ConfigureServices() public static method

public static ConfigureServices ( IMvcBuilder mvcBuilder ) : void
mvcBuilder IMvcBuilder
return void
Exemplo n.º 1
0
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration
     .ConfigureServices(services)
     .AddOpenApi()
     .AddDbContext(configuration);
 }
Exemplo n.º 2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services) =>
 ApiConfiguration.ConfigureServices(services, Environment)
 .AddCustomServices()
 .AddOpenApi()
 .AddCors(options => options.AddPolicy("CorsApi",
                                       builder => builder.WithOrigins(
                                           "http://localhost:4200",
                                           "http://localhost:3000",
                                           "http://localhost:8080")
                                       .AllowAnyHeader().AllowAnyMethod()))
 .AddEntityFrameworkCore(Configuration)
 .AddMediatr()
 .AddOpenTelemetryTracing(builder => builder
                          .AddAspNetCoreInstrumentation()
                          .AddHttpClientInstrumentation()
                          .AddJaegerExporter()
                          .AddZipkinExporter()
                          )
 .AddCustomHealthChecks(Configuration)
 .AddHashids(setup => {
     setup.Salt          = "your_salt";
     setup.MinHashLength = 16;
 })
 .AddSwaggerGen(c => c.OperationFilter <HashIdsOperationFilter>())
 .AddResponseCompression()
 ;
Exemplo n.º 3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration.ConfigureServices(services)
     .AddCors()
     .AddDbContext <ShopContext>(options =>
     {
         options.UseSqlServer(@"Server=.;Database=Shop;Trusted_Connection=True;");
     });
 }
Exemplo n.º 4
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 http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            // Register Authentication
            services.AddAuthentication(options =>
            {
                options.DefaultScheme = TestServerAuthenticationDefaults.AuthenticationScheme;
            })
            .AddTestServerAuthentication();

            ApiConfiguration.ConfigureServices(services);
        }
Exemplo n.º 5
0
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration.ConfigureServices(services)
     .AddDbContext <NotesContext>(options =>
     {
         options.UseSqlServer(configuration.GetConnectionString(Constants.SqlServer), sqlOptions =>
         {
             sqlOptions.MigrationsAssembly(typeof(TestStartup).Assembly.FullName);
         });
     });
 }
Exemplo n.º 6
0
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration.ConfigureServices(services)
     .AddDbContextPool <ApiDbContext>(options =>
     {
         options.UseSqlServer(Configuration.GetConnectionString("SqlServer"), sqlOptions =>
         {
             sqlOptions.MigrationsAssembly(typeof(Startup).Assembly.GetName().Name);
         });
     })
     .AddControllers();
 }
Exemplo n.º 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Register Authentication
            services.AddAuthentication(options =>
            {
                options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(options =>
            {
                options.Authority = "https://localhost:8000";
            });

            ApiConfiguration.ConfigureServices(services);
        }
Exemplo n.º 8
0
        public void ConfigureServices(IServiceCollection services)
        {
            ApiConfiguration.ConfigureServices(services);
            services
            .AddAuthentication(TestServerDefaults.AuthenticationScheme)
            .AddTestServer();

            services
            .AddDbContext <ShopContext>(options =>
            {
                // appsettings.json, Copy to Output Directory: Copy if newer
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
            });
        }
Exemplo n.º 9
0
    public void ConfigureServices(IServiceCollection services)
    {
        // Register Authentication
        services.AddAuthentication(options =>
        {
            options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
        })
        .AddJwtBearer(options =>
        {
            options.Authority = "https://localhost:5001";
        });

        var mvcBuilder = services.AddControllers();

        ApiConfiguration.ConfigureServices(mvcBuilder);
    }
Exemplo n.º 10
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 http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            // Register Authentication
            services.AddAuthentication(options =>
            {
                options.DefaultScheme = TestServerDefaults.AuthenticationScheme;
            })
            .AddTestServer()
            // We can register as many TestServer authentication options with different scheme names
            .AddTestServer("bearer", options =>
            {
                options.NameClaimType = "name";
                options.RoleClaimType = "role";
            })
            .AddTestServer("extra");

            ApiConfiguration.ConfigureServices(services);
        }
Exemplo n.º 11
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 http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            // Register Authentication
            services.AddAuthentication(options =>
            {
                options.DefaultScheme = TestServerDefaults.AuthenticationScheme;
            })
            .AddTestServer()
            // We can register as many TestServer authentication options with different scheme names
            .AddTestServer("bearer", options =>
            {
                options.NameClaimType = "name";
                options.RoleClaimType = "role";
            })
            .AddTestServer("extra");

            var mvcBuilder = services.AddControllers()
                             .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            ApiConfiguration.ConfigureServices(mvcBuilder);
        }
Exemplo n.º 12
0
        public void ConfigureServices(IServiceCollection services)
        {
            ApiConfiguration.ConfigureServices(services, Configuration, Environment);
            services.AddDistributedMemoryCache();
            services.AddOpenApi();

            var origins = new string[] { "http://localhost:4200", "https://localhost:4200", "http://localhost:3000" };

            services.AddCors(options =>
            {
                options.AddPolicy(AllowedOrigins,
                                  builder =>
                {
                    builder.WithOrigins(origins)
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddEntityFrameworkCore(Configuration)
            .AddCustomDbContext(Configuration);
        }
Exemplo n.º 13
0
        public void ConfigureServices(IServiceCollection services)
        {
            ApiConfiguration.ConfigureServices(services, _configuration, _hostEnvironment)
            .AddDistributedMemoryCache()
            .RegisterSwaggerExtensions(ApiConstants.ApiTitleV1, ApiConstants.ApiVersionV1)
            .AddCors(options => options.AddPolicy(AllowedOriginsPolicy, corsbuilder =>
            {
                var allowedOrigins =
                    _configuration.GetSection <Cors>().AllowedOrigins?.Split(";") ??
                    throw new ArgumentNullException(AllowedOriginsPolicy);
                corsbuilder.AllowAnyOrigin()
                .AllowAnyHeader()
                .AllowAnyMethod()
                .WithOrigins(allowedOrigins);
            }))
            .AddControllers();

            if (IsOnlyApi())
            {
                return;
            }
            services.AddSpaStaticFiles(configuration => configuration.RootPath = SpaStaticsPath);
        }
Exemplo n.º 14
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 http://go.microsoft.com/fwlink/?LinkID=398940
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration.ConfigureServices(services);
 }
Exemplo n.º 15
0
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration.ConfigureServices(services)
     .AddAuthentication(TestServerAuthenticationDefaults.AuthenticationScheme)
     .AddTestServerAuthentication();
 }
Exemplo n.º 16
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration.ConfigureServices(services)
     .AddAuthentication()
     .AddJwtBearer();
 }
Exemplo n.º 17
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration.ConfigureServices(services, Environment, Configuration);
 }
Exemplo n.º 18
0
 public void ConfigureServices(IServiceCollection services)
 {
     ApiConfiguration.ConfigureServices(services, _configuration, _hostingEnvironment)
     .AddAuthentication(options => options.DefaultScheme = TestServerDefaults.AuthenticationScheme)
     .AddTestServer();
 }