// This method gets called by the runtime. Use this method to add services to the container. public static void ApiConfigureServices(IServiceCollection services, IConfiguration config) { services.AddMvc(options => { options.Filters.Add(typeof(ApiAuthentication)); }) .AddFluentValidation(configs => { configs.RegisterValidatorsFromAssemblyContaining <WebApiStartup>(); configs.RunDefaultMvcValidationAfterFluentValidationExecutes = false; }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddHttpContextAccessor(); services.AddScoped(typeof(IRepository <>), typeof(Repository <>)); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddSingleton <IConfiguration>(config); System.Web.HttpContext.Configure(services); DependencyProvider.Configure(); }