Ejemplo n.º 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 void ConfigureServices(IServiceCollection services)
        {
            CompositionRoot.InjectDependencies(services, _configuration);

            services.AddControllersWithViews();

            services.AddScoped <INamedPlayersGetter, NamedPlayersGetter>();
            services.AddScoped <INamedPlayersToSelectListConverter, NamedPlayersToSelectListConverter>();
        }
Ejemplo n.º 2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     CompositionRoot.InjectDependencies(services);
     services.AddAutoMapper(typeof(Startup));
     services.AddDbContext <ApplicationDbContext>(options =>
                                                  options.UseSqlServer(
                                                      Configuration.GetConnectionString("DefaultConnection")));
     services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false)
     .AddEntityFrameworkStores <ApplicationDbContext>();
     services.AddControllersWithViews();
     services.AddRazorPages();
 }
Ejemplo n.º 3
0
        public void ConfigureServices(IServiceCollection services)
        {
            CompositionRoot.InjectDependencies(services, Configuration.GetConnectionString("MSSQL_DEV_CONN"));

            services.AddControllers().AddNewtonsoftJson(opt =>
            {
                opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            });
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Shortener.Api", Version = "v1"
                });
            });
        }
Ejemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CompositionRoot.InjectDependencies(services, Configuration, c => {
                c.AddProfile(typeof(DTOToViewModelsMappingProfile));
                c.AddProfile(typeof(DTOToEntitiesMappingProfile));
                c.AddProfile(typeof(EntitiesToDTOMappingProfile));
            });

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "HotelManager.API", Version = "v1"
                });
            });
        }
Ejemplo n.º 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CompositionRoot.InjectDependencies(services, Configuration);

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Mentoring.WEB.API", Version = "v1"
                });
            });
            services.AddCors(o => o.AddPolicy("ForReactClient", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));
        }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            CompositionRoot.AddDbContext(services, Configuration);
            CompositionRoot.InjectDependencies(services);

            services.AddAutoMapper(config =>
            {
                config.AddProfile <ApiMappingProfile>();
                config.AddProfile <BusinessMappingProfile>();
            }, typeof(Startup));

            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "NLayer API", Version = "v1"
                });
            });
        }
Ejemplo n.º 7
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
            CompositionRoot.InjectDependencies(services, Configuration);
            services.AddControllers();
            //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "DotNet Core API With CodeFirst",
                    Version     = "v1",
                    Description = "DotNet Core 3.1 API With Entity Framework Code First Approach"
                });

                //Locate the XML file being generated by ASP.NET...
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.XML";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);

                //... and tell Swagger to use those XML comments.
                c.IncludeXmlComments(xmlPath);
            });
        }
Ejemplo n.º 8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CompositionRoot.InjectDependencies(services, Configuration);

            var authOptions = new AuthOptions();

            Configuration.GetSection("AuthOptions").Bind(authOptions);

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.RequireHttpsMetadata      = false;
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidIssuer              = authOptions.ISSUER,
                    ValidateAudience         = true,
                    ValidAudience            = authOptions.AUDIENCE,
                    ValidateLifetime         = true,
                    IssuerSigningKey         = authOptions.GetSymmetricSecurityKey(),
                    ValidateIssuerSigningKey = true,
                    ClockSkew = TimeSpan.Zero
                };
            });

            services.AddCors();

            services.AddControllers()
            .AddJsonOptions(options =>
                            options.JsonSerializerOptions.Converters.Add(new TimeSpanConverter()));

            // EasyNetQ Congiguration through extension
            services.AddEasyNetQ(Configuration.GetConnectionString("RabbitMQ"));

            // AutoMapper Configurations
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new ModelMappingProfile());
            });

            services.AddSingleton(mappingConfig.CreateMapper());

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "CharlieBackend", Version = "19.11.2020"
                });
                c.ExampleFilters();
                c.OperationFilter <AddResponseHeadersFilter>();

                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);

                c.IncludeXmlComments(xmlPath);

                c.OperationFilter <AppendAuthorizeToSummaryOperationFilter>();
                c.OperationFilter <SecurityRequirementsOperationFilter>();
                c.IncludeXmlComments(xmlPath);

                c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
                {
                    Description = "Specify a Bearer token. \nExample: Bearer yJhbGciOiJIUzI1iIsInR5cCI6IkpXVCJ9",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey,
                    Scheme      = "Bearer"
                });
                c.AddSecurityRequirement(new OpenApiSecurityRequirement()
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            },
                            Scheme = "oauth2",
                            Name   = "Bearer",
                            In     = ParameterLocation.Header,
                        },
                        new List <string>()
                    }
                });
            });

            services.Configure <SwaggerOptions>(c => c.SerializeAsV2 = true);

            services.AddSwaggerExamplesFromAssemblyOf <Startup>();
        }
Ejemplo n.º 9
0
 public void ConfigureServices(IServiceCollection services)
 {
     CompositionRoot.InjectDependencies(services);
     services.AddControllersWithViews();
     services.AddTransient <IFileUpload, FileSystemFileUploader>();
 }
Ejemplo n.º 10
0
 public void ConfigureServices(IServiceCollection services)
 {
     CompositionRoot.InjectDependencies(services);
     services.AddControllers();
 }