// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            DependencyRegistrations.Register(services);

            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity <ApplicationUser>()
            .AddDefaultUI(UIFramework.Bootstrap4)
            .AddEntityFrameworkStores <ApplicationDbContext>();

            services
            .AddJsEngineSwitcher(options => options.DefaultEngineName = ChakraCoreJsEngine.EngineName)
            .AddChakraCore(s => { s.DisableFatalOnOOM = true; });
            services.AddReact();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddJsonOptions(x =>
            {
                x.SerializerSettings.ContractResolver = new DefaultContractResolver
                {
                    NamingStrategy = new SnakeCaseNamingStrategy()
                };
            });
        }
Exemplo n.º 2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RouteConfig.RegisterRoutes(RouteTable.Routes);
            GlobalConfiguration.Configure(WebApiConfig.Register);

            IUnityContainer container = DependencyRegistrations.Register();

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));

            FilterProviders.Providers.Remove(FilterProviders.Providers.OfType <FilterAttributeFilterProvider>().First());
            FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(container));

            GlobalFilters.Filters.Add(new ErrorHandler(container.Resolve <IErrorService>()));

            Vault.Init();
        }
Exemplo n.º 3
0
        public static void Register(HttpConfiguration config)
        {
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());

            IUnityContainer container = DependencyRegistrations.Register();

            config.DependencyResolver = new WebApiUnityDependencyResolver(container);

            List <IFilterProvider> filterProviders       = config.Services.GetFilterProviders().ToList();
            IFilterProvider        defaultFilterProvider = filterProviders.Single(p => p is ActionDescriptorFilterProvider);

            config.Services.Remove(typeof(IFilterProvider), defaultFilterProvider);
            config.Services.Add(typeof(IFilterProvider), new WebApiUnityFilterProvider(container));
        }
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
     DependencyRegistrations.Register(services);
 }