Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc()
            //.AddCustomSwagger()
            //.AddApplicationDI()
            .AddFluentValidation()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
            });

            ConfigureSwagger(services);

            services.Configure <DatabaseOptions>(Configuration.GetSection("Database"));

            services.AddCors(o => o.AddPolicy("DefaultPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            services.Configure <MvcOptions>(options =>
            {
                options.Filters.Add(new CorsAuthorizationFilterFactory("DefaultPolicy"));
            });

            services.AddLogging((logging) =>
            {
                logging.AddConsole();
                logging.AddEventSourceLogger();
            });

            Bootstraper.Configure(services);

            MongoDbMapper.MapClasses();
        }