Exemple #1
0
        // 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);
            }
        }
Exemple #2
0
        // 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();
        }
Exemple #3
0
        // 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);
            }
        }
Exemple #4
0
        // 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);
            }
        }
Exemple #5
0
 private static void RegisterServices(IServiceCollection services)
 {
     // Adding dependencies from another layers (isolated from Presentation)
     NativeDependencyInjection.RegisterServices(services);
 }
 private static void RegisterServices(IServiceCollection services)
 {
     NativeDependencyInjection.RegisterServices(services);
 }