예제 #1
0
 public static void Setup <BaseIContentType>(
     Func <ICrud> getCrud, Func <ISecretService> getSecretService,
     Func <string> getContentViewPath, Func <string> getContentPageUrl,
     SaveFile getSaveFile, DeleteFile getDeleteFile,
     Func <SystemConfig> config, Func <IModelService> modelService)
     where BaseIContentType : class, IContentModel
 {
     ContentPostViewModel.Init(getContentViewPath, getContentPageUrl);
     MyReflectExtends.Init(getCrud);
     AbstractBaseContent.Init <BaseIContentType>(getCrud);
     PassModeConvert.Init(getSaveFile, getDeleteFile, getCrud, getSecretService);
     TypeExtends.Init <BaseIContentType>(config, modelService);
 }
예제 #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSession();
            services.AddHttpContextAccessor();


            services.Configure <SystemConfig>(Configuration.GetSection("SystemConfig"));
            services.Configure <AdminAreaConfig>(Configuration.GetSection("AdminAreaConfig"));
            services.Configure <LanguageSetting>(Configuration.GetSection("LanguageSetting"));
            //services.Configure<IEnumerable<LanguageConfig>>(Configuration.GetSection("LanguageSetting:LanguageConfigs"));
            //var tokenConfig1 = Configuration.GetSection("LanguageSetting").Get<LanguageSetting>();
            //var language = Configuration.GetSection("LanguageSetting").Get<LanguageSetting>();
            //language.LanguageConfigs = Configuration.GetSection("LanguageSetting:LanguageConfigs").Get<IEnumerable<LanguageConfig>>();


            services.AddScoped <ISessionService, SessionService>();

            services.AddScoped <IAdminTempleteRoot, Common.AdminLTE.Program>();
            services.AddScoped <IConfigService, ConfigService>();

            services.AddScoped <ISDHCLanguageService, SDHCLanguageService>();


            services.AddControllersWithViews();
            services.AddRazorPages();
            services.AddServerSideBlazor();

            var builder = new DbContextOptionsBuilder <MyDBContext>();

            Action <DbContextOptionsBuilder> dbAction = options =>
            {
                options.UseSqlServer(
                    Configuration.GetConnectionString("DefaultConnection"));
            };

            services.AddDbContext <MyDBContext>(dbAction);

            services.AddIdentity <SDHCUser, IdentityRole>(
                options =>
            {
                options.SignIn.RequireConfirmedAccount = false;
            })
            .AddEntityFrameworkStores <MyDBContext>()
            .AddDefaultTokenProviders();

            services.AddScoped <RoleManager <IdentityRole> >();
            services.AddScoped(typeof(ISDHCMemberService <SDHCUser, IdentityResult, Claim, ClaimsPrincipal, UserLoginInfo, IUserValidator <SDHCUser>, IUserTwoFactorTokenProvider <SDHCUser> >), typeof(SDHCMemberService <SDHCUser>));
            services.AddScoped(typeof(ISDHCSignInService <SDHCUser, IdentityResult, Claim, SignInResult, ClaimsPrincipal, AuthenticationProperties, AuthenticationScheme, ExternalLoginInfo>), typeof(SDHCSignInService <SDHCUser>));
            services.AddScoped <ISDHCUserManager <SDHCUser>, SDHCUserManager <SDHCUser> >();
            services.AddScoped <ISDHCUserManager, SDHCUserManager <SDHCUser> >();

            StartUpFunction.ConfigureServices <SDHCUserManager <SDHCUser> >(Configuration, services);

            services.AddScoped <AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider <SDHCUser> >();

            services.AddScoped <IUserService, UserService>();

            services.AddScoped <IUserServiceStateProvider, UserServiceAuthenticationStateProvider>();


            dbAction(builder);
            Func <CrudInit <BaseContentModel> > getCrud = () => new CrudInit <BaseContentModel>(() => Activator.CreateInstance(typeof(MyDBContext), builder.Options) as ISave);

            services.AddScoped <ICrudInit, CrudInit <BaseContentModel> >(
                (s) => getCrud());


            services.AddScoped <ICrud, BaseCruds>();
            services.AddScoped <ICrudContent, CrudContent>();
            services.AddScoped <ICrudModel, CrudModel>();
            AbstractBaseContent.Init <BaseContentModel>(() => new CrudContent(getCrud()));
            services.AddScoped <IContentService, ContentService>();
            services.AddScoped <IContentListService, ContentService>();


            services.AddScoped <ILayoutService, LayoutService>();
        }