Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMemoryCache();
            services.AddSession();
            services.AddMvc(options =>
            {
                options.AddComBoostMvcDataOptions();
            });
            services.AddComBoostMvcAuthentication <ComBoostAuthenticationSessionHandler>();

            services.AddScoped <DbContext, DataContext>(serviceProvider =>
                                                        new DataContext(new DbContextOptionsBuilder <DataContext>().UseInMemoryDatabase("Test")
                                                                        .Options));
            services.AddScoped <IDatabaseContext, DatabaseContext>();
            services.AddScoped <ISecurityProvider, ForumSecurityProvider>();
            services.AddScoped <IAuthenticationProvider, ComBoostAuthenticationProvider>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <IDomainServiceAccessor, DomainServiceAccessor>();
            services.AddSingleton <IActionContextAccessor, ActionContextAccessor>();
            services.AddSingleton <ICacheProvider, MemoryCacheProvider>();
            services.AddSingleton <ISerializerProvider, JsonSerializerProvider>();
            services.AddScoped <IStorageProvider, PhysicalStorageProvider>(t =>
            {
                return(new PhysicalStorageProvider(PhysicalStorageOptions.CreateDefault(_Env.ContentRootPath + System.IO.Path.DirectorySeparatorChar + "Uploads")));
            });
            services.AddSingleton <IDomainServiceProvider, DomainProvider>(t =>
            {
                var provider = new DomainProvider(t);
                provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntitySearchExtension <>));
                provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntityPagerExtension <>));
                provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntityPasswordExtension <>));
                provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(ImageExtension <>));
                provider.AddForumExtensions();
                provider.AddGlobalFilter <AliasFilter>();
                return(provider);
            });

            EntityDescriptor.InitMetadata(typeof(Board).Assembly);
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMemoryCache();
            services.AddSession();
            services.AddMvc(options =>
            {
                options.AddComBoostMvcDataOptions();
            });
            services.AddComBoostMvcAuthentication <ComBoostAuthenticationCookieHandler>();

            services.AddScoped <DbContext, DataContext>(serviceProvider =>
                                                        new DataContext(new DbContextOptionsBuilder <DataContext>().UseInMemoryDatabase("Test")
                                                                        //new DataContext(new DbContextOptionsBuilder<DataContext>().UseSqlServer(Configuration.GetConnectionString("DataContext"))
                                                                        .Options));
            services.AddScoped <IDatabaseContext, DatabaseContext>();
            services.AddScoped <ISecurityProvider, ForumSecurityProvider>();
            services.AddScoped <IAuthenticationProvider, ComBoostAuthenticationProvider>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <IDomainServiceAccessor, DomainServiceAccessor>();
            services.AddSingleton <IActionContextAccessor, ActionContextAccessor>();
            services.AddSingleton <ICacheProvider, MemoryCacheProvider>();
            services.AddSingleton <ISerializerProvider, AspNetCore.JsonSerializerProvider>();
            services.AddScoped <IStorageProvider, PhysicalStorageProvider>(t =>
            {
                return(new PhysicalStorageProvider(PhysicalStorageOptions.CreateDefault(_Env.ContentRootPath + System.IO.Path.DirectorySeparatorChar + "Uploads")));
            });
            services.AddSingleton <IDomainServiceProvider, DomainProvider>(t =>
            {
                var provider = new DomainProvider(t);
                provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntitySearchExtension <>));
                provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntityPagerExtension <>));
                provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(EntityPasswordExtension <>));
                provider.AddGenericDefinitionExtension(typeof(EntityDomainService <>), typeof(ImageExtension <>));
                provider.AddForumExtensions();
                return(provider);
            });
        }