コード例 #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);
            }
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: JOliveiraProjects/Livraria
        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);
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: beirinha/StoreCatalog
        // 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();
        }
コード例 #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)
                .ConfigureJsonOptions();

                services.AddMediatR(typeof(Startup).Assembly);

                services.AddHttpContextAccessor();

                NativeDependencyInjection.RegisterServices(services);
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }
コード例 #5
0
        // 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();
        }
コード例 #6
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);
            }
        }
コード例 #7
0
 public static void AddDependencyInjection(this IServiceCollection services)
 {
     NativeDependencyInjection.RegisterDependencyInjection(services);
 }
コード例 #8
0
 private static void RegisterService(IServiceCollection services)
 {
     NativeDependencyInjection.RegisterServiceCollection(services);
 }
コード例 #9
0
 private static void RegisterServices(IServiceCollection services)
 {
     // Adding dependencies from another layers (isolated from Presentation)
     NativeDependencyInjection.RegisterServices(services);
 }