示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDistributedMemoryCache();

            services.AddSession(options =>
            {
                options.IdleTimeout        = TimeSpan.FromSeconds(10);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
            });

            // CONFIGURAÇÃO DA CONEXÃO COM O DB E O CONTEXT
            var connection = Configuration["ConexaoSqlite:SqliteConnectionString"];

            ConfigureContext <MyContext> .Configure(services, connection);

            // CONFIGURAÇÃO DA INJEÇÃO DE DEPENDÊNCIA
            ConfigureDependencyInjection.Configuration(services);

            services.AddControllers().AddNewtonsoftJson(options =>
                                                        options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                                                        );

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddControllersWithViews();
        }
示例#2
0
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureDependencyInjection.InjectDataRepositories(services);
            ConfigureDependencyInjection.InjectBusisnessWorkflows(services);
            ConfigureDependencyInjection.InjectFactories(services);

            services.AddCors();

            services.AddControllers();
            services.AddAutoMapper(typeof(Startup));
            services.AddDbContext <TaxCalculatorContext>(options => options.UseSqlServer(Configuration.GetConnectionString("TaxCalculatorConnectionString"), options => options.EnableRetryOnFailure()));
        }
示例#3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            ConfigureDependencyInjection.DependenciesRepository(services);
            ConfigureDependencyInjection.DependenciesService(services);
            ConfigureDependencyInjection.DependenciesValidation(services);

            services.AddAutoMapper(typeof(Mapping));

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Teste Luby API", Version = "v1"
                });
            });
        }