public static void Configure(IServiceCollection services)
        {
            //foreach (var type in IoC.Module.GetSingleTypes())
            //    services.AddScoped(type);

            Bootstraper.Configure(services);
        }
Example #2
0
        private void RegisterCustomControllerFactory()
        {
            //IControllerFactory factory = new CustomControllerFactory("TripProj.Controllers");
            DIContainer diContainer = new DIContainer();

            Bootstraper.Configure(diContainer);

            ControllerBuilder.Current.SetControllerFactory(new DICustomControllerFactory(diContainer));
        }
Example #3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddSingleton(_ => Configuration);
     Bootstraper.Initialize();
     Bootstraper.Configure(services);
     services.AddCors(options =>
     {
         options.AddPolicy("CorsPolicy",
                           corsPolicyBuilder => corsPolicyBuilder
                           .AllowAnyOrigin()
                           .AllowAnyMethod()
                           .AllowAnyHeader()
                           .AllowCredentials());
     });
     services.AddMvc();
 }
Example #4
0
        public void ConfigureServices(IServiceCollection services)
        {
            var section = Configuration.GetSection("WebApiConfiguration");

            services.Configure <WebApiConfiguration>(section);

            Bootstraper.Configure(services, Configuration);

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

            var key = Encoding.ASCII.GetBytes(Settings.Secret);

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            services.AddControllers(options =>
            {
                options.Filters.Add(typeof(CustomExceptionFilter));
            });

            services.AddAutoMapper();

            //services.AddAutoMapper(typeof(AutoMapperProfile).Assembly);
        }
Example #5
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();
        }