Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddReact();
            services.AddJsEngineSwitcher(options => options.DefaultEngineName = ChakraCoreJsEngine.EngineName).AddChakraCore();
            services.AddDistributedMemoryCache();
            services.AddSession();

            var dbContext = new InMemoryRepositoryContext();

            services.AddSingleton(x => new EfGenericRepository <Good>(dbContext) as IGenericRepository <Good>);
            services.AddSingleton(x => new EfGenericRepository <Catalog>(dbContext) as IGenericRepository <Catalog>);
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            var inMemoryContext = new InMemoryRepositoryContext();

            services.AddSingleton <CommonRepositoryContext>(new InMemoryRepositoryContext());
            services.AddSingleton <IGenericRepository <Good> >(new EfGenericRepository <Good>(inMemoryContext));
            services.AddSingleton <IGenericRepository <Catalog> >(new EfGenericRepository <Catalog>(inMemoryContext));

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
        }