// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { try { services .AddMvc(options => { options.AddNotificationAsyncResultFilter <NotificationAsyncResultFilter>(Configuration); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); //.Net core 3.0 //.AddNewtonsoftJson(); services.AddMediatR(typeof(Startup).Assembly); services.AddHttpContextAccessor(); NativeDependencyInjection.RegisterServices(services); services.AddDbContext <OrderContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); // Register the Swagger services services.AddSettingSwaggerDocument(); } catch (Exception ex) { Log(ex); } }
public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest); services.AddGlobalExceptionHandlerMiddleware(); // Ajustes relacionados à GDPR services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); // habilita a gravacao de sessao. services.AddSession(opts => { opts.Cookie.IsEssential = true; // make the session cookie Essential }); services.AddResponseCompression(); // Comprimir todas as requisicoes. services.AddHttpContextAccessor(); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder .SetIsOriginAllowed((host) => true) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "Livraria HTTP API", Version = "v1", Description = "Serviço Livraria HTTP API" }); }); NativeDependencyInjection dp = new NativeDependencyInjection(); dp.Configure(services, Configuration); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "StoreCatalog", Version = "v1" }); }); services.AddDbContext <StoreCatalogDbContext>(opt => opt.UseInMemoryDatabase("StoreCatalog")); var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new AutomapperProfile()); }); IMapper mapper = mappingConfig.CreateMapper(); services.AddSingleton(mapper); NativeDependencyInjection.RegisterServices(services); services.Configure <AppSettings>(appSettings => { appSettings.ProductsApiSettings = new ProductsApiSettings() { Url = Configuration["AppSettings:ProductsApiSettings:url"], }; appSettings.ProductionApiSettings = new ProductionApiSettings() { Url = Configuration["AppSettings:ProductionApiSettings:url"], }; appSettings.LojaSettings = new LojaSettings() { Nome = Configuration["AppSettings:LojaSettings:nome"], }; appSettings.IngredientsApiSettings = new IngredientsApiSettings() { Url = Configuration["AppSettings:IngredientsApiSettings:url"], }; }); services.AddMvcCore().AddFormatterMappings().AddJsonFormatters().AddCors().AddApiExplorer(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { try { services.AddMvc(options => { options.AddNotificationAsyncResultFilter <NotificationAsyncResultFilter>(Configuration); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .ConfigureJsonOptions(); services.AddMediatR(typeof(Startup).Assembly); services.AddHttpContextAccessor(); NativeDependencyInjection.RegisterServices(services); } catch (Exception ex) { Log(ex); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // configure strongly typed settings objects var appSettingsSection = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appSettingsSection); var appSettings = appSettingsSection.Get <AppSettings>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; }); var dp = new NativeDependencyInjection(); dp.Configure(services); AutoMapperConfig.RegisterMappings(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { try { services.AddMvc(options => { options.AddNotificationAsyncResultFilter <NotificationAsyncResultFilter>(Configuration); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); //.Net core 3.0 //.AddNewtonsoftJson(); services.AddHttpContextAccessor(); NativeDependencyInjection.RegisterServices(services); services.AddDbContext <CatalogContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddSingleton <IDataConfigurationProvider>(_ => new DataConfigurationProvider(Configuration.GetConnectionString("DefaultConnection"))); } catch (Exception ex) { Log(ex); } }
public static void AddDependencyInjection(this IServiceCollection services) { NativeDependencyInjection.RegisterDependencyInjection(services); }
private static void RegisterService(IServiceCollection services) { NativeDependencyInjection.RegisterServiceCollection(services); }
private static void RegisterServices(IServiceCollection services) { // Adding dependencies from another layers (isolated from Presentation) NativeDependencyInjection.RegisterServices(services); }