public static void Main() { //using (var dbContext = new EmployeesDbContext()) //{ // dbContext.Database.EnsureDeleted(); // dbContext.Database.EnsureCreated(); //} MapperInitializer.InitializeMapper(); var serviceProvider = ServiceInitializer.ConfigureServices(); var commandInterpreter = new CommandInterpreter(serviceProvider); var reader = new ConsoleReader(); var writer = new ConsoleWriter(); var engine = new Engine(reader, writer, commandInterpreter); engine.Run(); }
public void ConfigureServices(IServiceCollection services) { services.Configure <AuthOptions>(Configuration.GetSection("Token")); services.Configure <UploadPhotoApiOptions>(Configuration.GetSection("UploadPhotoApi")); services .AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(jwtBearerOptions => { jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuer = true, ValidIssuer = Configuration["Token:Issuer"], ValidateAudience = true, ValidAudience = Configuration["Token:Audience"], ValidateLifetime = true, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Token:Key"])) }; }); ServiceInitializer.ConfigureServices(services, Configuration); var mapper = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }) .CreateMapper(); services.AddSingleton(mapper); services.AddCors(); services.AddControllers(); services.Configure <ApiBehaviorOptions>(options => { options.InvalidModelStateResponseFactory = ctx => new ValidationErrorDetailsResult(); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <MyDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <MyDbContext>() .AddDefaultTokenProviders(); ServiceInitializer.ConfigureServices(services); services.Configure <AuthMessageSenderOptions>(Configuration); services.AddMvc(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ServiceInitializer.ConfigureServices(services, Configuration); var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }); var mapper = mappingConfig.CreateMapper(); services.AddSingleton(mapper); //services.AddMvc(options => //{ // options.Filters.Add(typeof(GlobalExceptionFilter)); //}); services.AddControllersWithViews(); services.AddMvc(); }
public void ConfigureServices(IServiceCollection services) { ServiceInitializer.ConfigureServices(services, Configuration); services.AddScoped <ErrorHelper>(); var supportedCultures = new[] { new CultureInfo("ru") }; services.Configure <RequestLocalizationOptions>(options => { options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); var mapper = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }) .CreateMapper(); services.AddSingleton(mapper); services.AddCors(); services.AddControllers(); }