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.AddMvc();

            //
            services.AddDbContextPool <GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), b => b.UseRowNumberForPaging()));

            services.AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = CookieAdminAuthInfo.AuthenticationScheme;
                o.DefaultChallengeScheme    = CookieAdminAuthInfo.AuthenticationScheme;
            })
            .AddCookie(CookieAdminAuthInfo.AuthenticationScheme, o =>
            {
                o.LoginPath = "/admin/login";
            });

            //程序集依赖注入
            services.AddAssembly("BLL");

            services.AddSession();

            //泛型注入到DI里面
            services.AddScoped(typeof(IRepository <>), typeof(EfRepository <>));

            services.AddScoped <IWorkContext, WorkContext>();
            services.AddScoped <IAdminAuthService, AdminAuthService>();
            services.AddSingleton <IMemoryCache, MemoryCache>();
            services.AddSingleton <IRegisterApplicationService, RegisterApplicationService>();
            //
            EnginContext.Initialize(new GeneralEngine(services.BuildServiceProvider()));
            ;
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
        }
Esempio n. 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            //数据库连接
            services.AddDbContextPool <GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));


            //添加认证信息
            services.AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = CookieAdminAuthInfo.AuthenticationScheme;
                o.DefaultChallengeScheme    = CookieAdminAuthInfo.AuthenticationScheme;
            })
            .AddCookie(CookieAdminAuthInfo.AuthenticationScheme, o =>
            {
                o.Cookie.Name = CookieAdminAuthInfo.AuthenticationScheme;
                o.LoginPath   = new PathString("/admin/login");
                o.LogoutPath  = new PathString("/admin/login");
            });

            services.AddSession();

            //程序集依赖注入
            services.AddAssembly("General.IService");
            services.AddAssembly("General.Service");
            //泛型注入到DI里面
            services.AddScoped(typeof(IRepositoryBase <>), typeof(RepositoryBase <>));
            services.AddScoped <IWorkContext, WorkContext>();
            services.AddScoped <ILoginAuthService, LoginAuthService>();
            services.AddSingleton <IMemoryCache, MemoryCache>();
            services.AddSingleton <IRegisterApplicationService, RegisterApplicationService>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            EnginContext.Initialize(new GeneralEngine(services.BuildServiceProvider()));
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            #region AddNLog
            //添加NLog
            //loggerFactory.AddNLog();
            //读取Nlog配置文件
            //env.ConfigureNLog("nlog.config");
            #endregion
            EnginContext.Initialize(new GeneralEngine(app.ApplicationServices));
            //获取前面注入的Quartz调度类
            var quartz = app.ApplicationServices.GetRequiredService <QuartzStartup>();
            appLifetime.ApplicationStarted.Register(() =>
            {
                quartz.Start().Wait(); //网站启动完成执行
            });

            appLifetime.ApplicationStopped.Register(() =>
            {
                quartz.Stop();  //网站停止完成执行
            });

            app.UseMvc();
        }
Esempio n. 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var assembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

            // 注入 EF上下文
            //services.AddDbContext<EFDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),b=>b.UseRowNumberForPaging()));
            //dotnet ef migrations add InitialEFDbContext -c EFDbContext -o Data/Migrations/DemoDB
            services.AddDbContextPool <EFDbContext>(options =>
                                                    options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), b => { b.UseRowNumberForPaging(); b.MigrationsAssembly(assembly); })
                                                    );

            // 注入 程序集依赖
            services.AddAssembly("Universal.Services");

            // 注入 泛型仓储
            services.AddScoped(typeof(IRepository <>), typeof(EFRepository <>));

            // 注入缓存
            services.AddSingleton <IMemoryCache, MemoryCache>();

            /*
             * ASP.NET Core中提供了一个IHttpContextAccessor接口,HttpContextAccessor 默认实现了它简化了访问HttpContext。
             * 它必须在程序启动时在IServicesCollection中注册,这样在程序中就能获取到HttpContextAccessor,并用来访问HttpContext。
             */
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            // 注入 Admin认证
            services.AddScoped <IAdminAuthService, AdminAuthService>();

            // 注入 用户登录后的状态
            services.AddScoped <IWorkContext, WorkContext>();

            // 注入 初始化菜单
            services.AddSingleton <IRegisterMenuService, RegisterMenuService>();

            // 注入 Session
            services.AddSession();

            // 注入 认证信息
            services.AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = CookieAdminAuthInfo.AuthenticationScheme;
                o.DefaultChallengeScheme    = CookieAdminAuthInfo.AuthenticationScheme;
            }).AddCookie(CookieAdminAuthInfo.AuthenticationScheme, o =>
            {
                o.LoginPath = "/admin/login";
            });

            // 初始化引擎
            EnginContext.Initialize(new UniversalEngine(services.BuildServiceProvider()));

            // 注入 MVC
            services.AddMvc(options =>
            {
                options.Filters.Add <HttpGlobalExceptionFilter>();
            });

            //services.AddMvc();
        }
Esempio n. 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //影响Session的使用1111111

            //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;
            //});


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            //数据库依赖注入
            services.AddDbContextPool <GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddSession();
            //权限注入
            services.AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = CookieAdminAuthInfo.AuthenticationScheme;
                o.DefaultChallengeScheme    = CookieAdminAuthInfo.AuthenticationScheme;
            }).AddCookie(CookieAdminAuthInfo.AuthenticationScheme, o =>
            {
                o.LoginPath = "/Admin/Login";
            });

            //测试拉取

            //单例注入
            //services.AddScoped<ICategoryService, CategoryService>();
            //提供者服务单例注入
            //services.BuildServiceProvider().GetService<ICategoryService>();


            //程序集依赖注入
            services.AddAssembly("General.Services");



            //泛型注入到DI内
            services.AddScoped(typeof(IRepository <>), typeof(EfRepository <>));

            services.AddHttpContextAccessor();
            services.AddScoped <IWorkContext, WorkContext>();
            services.AddScoped <IAdminAuthService, AdminAuthService>();
            services.AddSingleton <IMemoryCache, MemoryCache>();


            //引擎上下文提供服务初始化注入
            EnginContext.Initialize(new GeneralEngine(services.BuildServiceProvider()));
            //登录用户上下文

            //创建服务对象
            //new GeneralEngine(services.BuildServiceProvider());
            //services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
        }
Esempio n. 6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            #region AddNLog
            //添加NLog
            loggerFactory.AddNLog();
            //读取Nlog配置文件
            env.ConfigureNLog("nlog.config");
            #endregion
            EnginContext.Initialize(new GeneralEngine(app.ApplicationServices));
            //获取前面注入的Quartz调度类
            var quartz = app.ApplicationServices.GetRequiredService <QuartzStartup>();
            #region 远程读取日志
            FileExtensionContentTypeProvider provider = new FileExtensionContentTypeProvider();
            //  provider.Mappings[".log"] = "text/plain;charset=utf-8";
            provider.Mappings[".log"] = "text/plain;charset=utf-8";


            string basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider          = new PhysicalFileProvider(Path.Combine(basePath, "logs")),
                ServeUnknownFileTypes = true,
                RequestPath           = new PathString("/logs"),
                ContentTypeProvider   = provider,
                DefaultContentType    = "application/x-msdownload", // 设置未识别的MIME类型一个默认z值
            });
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(basePath, "logs")),
                RequestPath  = new PathString("/logs"),
            });
            #endregion

            appLifetime.ApplicationStarted.Register(() =>
            {
                quartz.Start().Wait(); //网站启动完成执行
            });

            appLifetime.ApplicationStopped.Register(() =>
            {
                quartz.Stop();  //网站停止完成执行
            });
            app.UseMvc();
        }
Esempio n. 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            //添加DbContext
            services.AddDbContextPool <GeneralDbContext>(option => option.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            //保证DbContext在一次请求中是同一个实列 默认是Scope
            //services.AddDbContext<GeneralDbContext>(option => option.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            //添加权限过滤
            services.AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = CookieAdminAuthInfo.AuthenticationScheme;
                o.DefaultChallengeScheme    = CookieAdminAuthInfo.AuthenticationScheme;
                //o.DefaultSignInScheme = "General";
                //o.DefaultSignOutScheme = "General";
            }).AddCookie(CookieAdminAuthInfo.AuthenticationScheme, o =>
            {
                o.LoginPath = "/admin/login";
            });

            services.AddSession();

            //添加服务
            //services.AddScoped<ICategoryService, CategoryService>();

            //程序集依赖注入,注入所有Services
            services.AddAssembly("General.Services");

            //泛型注入到DI里面
            services.AddScoped(typeof(IRepository <>), typeof(EfRepository <>));

            services.AddScoped <IWorkContext, WorkContext>();
            services.AddScoped <IAuthenticationService, AuthenticationService>();
            services.AddSingleton <IMemoryCache, MemoryCache>();

            //services.BuildServiceProvider().GetService<ICategoryService>();
            //new GeneralEngin(services.BuildServiceProvider());
            EnginContext.Initialize(new GeneralEngin(services.BuildServiceProvider()));

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
        }
Esempio n. 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseSession();

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "area",
                    pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            #region Autofac依赖注入服务
            // AutofacEngine.Container = app.ApplicationServices.GetAutofacRoot();
            #endregion

            EnginContext.Initialize(new GeneralEngine(app.ApplicationServices.GetAutofacRoot()));

            //初始化菜单
            EnginContext.Current.Resolve <IRegisterApplicationService>().initRegister();
        }
Esempio n. 9
0
 protected override Window CreateShell()
 {
     EnginContext.Initialize(new GeneralEngine(Container));
     return(Container.Resolve <MainWindow>());
 }
Esempio n. 10
0
        // 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;
            });

            services.AddMvc();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //services.AddDbContextPool<GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            //一个实例,保证过个实例互相不干扰
            //services.AddDbContext<GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            //真乱又让用pool了?
            services.AddDbContextPool <GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));


            //------------------------------- 成品项目中重新写
            //#Kevin 添加权限过滤
            //services.AddAuthentication();
            //services.AddAuthentication("General").AddCookie(o=>
            //{
            //    o.LoginPath = "/Admin/Login/Index";
            //});
            //----------------------------------

            services.AddAuthentication(o => {
                //o.DefaultAuthenticateScheme = "General";
                //o.DefaultChallengeScheme = "General";
                //o.DefaultSignInScheme = "General";
                //o.DefaultSignOutScheme = "General";    //都找这个名字的cookie值
                o.DefaultAuthenticateScheme = CookieAdminAuthInfo.AuthenticationScheme;
                o.DefaultChallengeScheme    = CookieAdminAuthInfo.AuthenticationScheme;
            }).AddCookie(CookieAdminAuthInfo.AuthenticationScheme, o =>
            {
                // o.LoginPath = "/Admin/Login/Index";
                o.LoginPath = "/admin/login";
            });



            //单个的注入可以注释掉了
            //services.AddScoped<ICategoryService, CategoryService>();
            //services.AddScoped<ISettingService, SettingService>();  //加一个表就得加一个,这要是很多可咋办

            //这个写在了extension中
            // var assembly=RuntimeHelper.GetAssemblyByName("General.Services");

            //var types = assembly.GetTypes();
            //var list = types.Where(o => o.IsClass && !o.IsAbstract && !o.IsGenericType).ToList();

            //foreach(var type in list)
            //{
            //    var interfacesList = type.GetInterfaces();
            //    if (interfacesList.Any())
            //    {
            //        var inter = interfacesList.First();
            //        services.AddScoped(inter, type);    //注入了后再homecongtroller中使用了
            //    }
            //}

            //程序集依赖注入
            services.AddAssembly("General.Services");

            services.AddSession();



            //泛型注入到Di里面
            services.AddScoped(typeof(IRepository <>), typeof(EfRepository <>));

            services.AddScoped <IWorkContext, WorkContext>();
            services.AddScoped <IAdminAuthService, AdminAuthService>();

            services.AddSingleton <IMemoryCache, MemoryCache>();
            //services.BuildServiceProvider().GetService<ICategoryService>();

            services.AddSingleton <IRegisterApplicationService, RegisterApplicationService>();


            //#Kevin 引入引擎机制
            EnginContext.Initialize(new GeneralEngine(services.BuildServiceProvider()));

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
        }
Esempio n. 11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();   //MVC的服务
            //services.AddAntiforgery(o => o.HeaderName = "XSRF-TOKEN");  //ajax 后台调用非api  没用啊?

            //services.AddDbContextPool<GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            //services.AddDbContext<GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); //一个实例

            //services.AddDbContext<GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")),ServiceLifetime.Transient); //两个对象
            //services.AddDbContextPool<GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddDbContextPool <GeneralDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), b => b.UseRowNumberForPaging()));  //解决低版本数据库不支持offset next的问题

            var test = Configuration.GetValue <string>("FR_ConnectionStrings");

            //services.AddAuthentication();   //权限过滤

            services.AddAuthentication(o => {
                o.DefaultAuthenticateScheme = CookieAdminAuthInfo.AuthenticationScheme;
                o.DefaultChallengeScheme    = CookieAdminAuthInfo.AuthenticationScheme;
                //o.DefaultAuthenticateScheme ="General";
                //o.DefaultChallengeScheme = "General";
                // o.DefaultSignInScheme= "General";
                // o.DefaultSignOutScheme= "General";
            }).AddCookie(CookieAdminAuthInfo.AuthenticationScheme, o =>
            {
                // o.LoginPath = "/Admin/Login/index";
                o.LoginPath = "/admin/login";
            });


            //.AddAuthentication(o => {
            //    o.DefaultAuthenticateScheme = CookieOrdinaryAuthInfo.AuthenticationScheme;
            //     o.DefaultChallengeScheme = CookieOrdinaryAuthInfo.AuthenticationScheme;
            //o.DefaultAuthenticateScheme ="General";
            //o.DefaultChallengeScheme = "General";
            // o.DefaultSignInScheme= "General";
            // o.DefaultSignOutScheme= "General";
            // }).AddCookie(CookieOrdinaryAuthInfo.AuthenticationScheme, o =>
            // {
            // o.LoginPath = "/Admin/Login/index";
            //     o.LoginPath = "/ordinary/login";

            // });

            //程序集依赖注入
            //var assembly =RuntimeHelper.GetAssemblyByName("General.Services");

            //var types= assembly.GetTypes();


            //services.AddScoped<ICategoryService, CategoryService>();
            //services.AddScoped<ISettingService, SettingService>();  //也不能写100多个吧?  服务+类名的度一应

            //services.BuildServiceProvider().GetService<ICategoryService>();

            // var assembly= RuntimeHelper.GetAssemblyByName("General.Services");

            //  var types = assembly.GetTypes();
            //var list =  types.Where(o => o.IsClass && !o.IsAbstract && !o.IsGenericType).ToList();  //把这里的类筛选出来
            //  foreach (var type in list)
            //  {
            //    var interfacesList=  type.GetInterfaces();  //找接口
            //      if (interfacesList.Any())
            //      {
            //          var inter = interfacesList.First();
            //          services.AddScoped(inter,type);  //把services里面的类  就是那两个Category、Setting获取出来
            //      }
            //  }


            //程序集依赖注入
            services.AddAssembly("General.Services");
            //services.AddAssembly("abc");

            services.AddSession();

            //泛型注入到DI里面
            services.AddScoped(typeof(IRepository <>), typeof(EfRepository <>));


            services.AddScoped <IWorkContext, WorkContext>();
            services.AddScoped <IAdminAuthService, AdminAuthService>();
            // services.AddScoped<IOrdinaryAuthService, OrdinaryAuthService>();
            services.AddSingleton <IMemoryCache, MemoryCache>();

            services.AddSingleton <IRegisterApplicationService, RegisterApplicationService>();

            EnginContext.Initialize(new GeneralEngine(services.BuildServiceProvider()));
            //new GeneralEngine(services.BuildServiceProvider());

            //泛型注入到DI里面
            //services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();   //关于http请求的注入
        }
Esempio n. 12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.Configure <ConfigOption>("LuckyConfig", Configuration.GetSection("ConfigOption"));
            //解决视图输出内容中文编码问题
            services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => false; //当为true时不能保存cookie到客户端
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddMvc(option =>
                            option.Filters.Add(new GlobalExceptionFilter()))
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddControllersAsServices()
            .AddFluentValidation(fv =>
            {
                //去掉其他的验证,只使用FluentValidation的验证规则
                fv.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
            });

            services.AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = CookieAdminAuthInfo.AuthenticationScheme;
                o.DefaultChallengeScheme    = CookieAdminAuthInfo.AuthenticationScheme;
            })
            .AddCookie(CookieAdminAuthInfo.AuthenticationScheme, options =>
            {
                options.LoginPath      = "/login";
                options.LogoutPath     = "/Account/Logout";
                options.ExpireTimeSpan = TimeSpan.FromMinutes(15);
            });
            //services.AddAntiforgery(options =>
            //{
            //       // Set Cookie properties using CookieBuilder properties†.
            //    options.FormFieldName = "AntiforgeryKey_yilezhu";
            //    options.HeaderName = "X-CSRF-TOKEN-yilezhu";
            //    options.SuppressXFrameOptionsHeader = false;
            //});
            string str = Configuration["ConfigOption:ConnectionString"];

            services.AddDbContextPool <GeneralDbContext>(options => options.UseSqlServer(Configuration["ConfigOption:ConnectionString"]));
            services.AddSession(options =>
            {
                options.IdleTimeout     = TimeSpan.FromMinutes(15);
                options.Cookie.HttpOnly = true;     //设置为后台只读模式,前端无法通过JS来获取cookie值,可以有效的防止XXS攻击
            });

            #region 缓存 读取配置是否使用哪种缓存模式
            services.AddMemoryCache();
            if (Convert.ToBoolean(Configuration["ConfigOption:IsUseRedis"]))
            {
                services.AddDistributedRedisCache(option =>
                {
                    option.Configuration = Configuration["ConfigOption:Redisconfig"];
                    option.InstanceName  = "RedisCacheTest";
                });
                services.AddSingleton <ICache, RedisCacheService>();
            }
            else
            {
                //services.AddSingleton<ICache, MemoryCacheService>();
                services.AddSingleton <ICache, NuLLCacheService>();
            }
            #endregion
            //DI了AutoMapper中需要用到的服务,其中包括AutoMapper的配置类 Profile
            services.AddAutoMapper();
            // services.AddDirectoryBrowser();

            ///   services.AddSingleton<ChatHub>() //可以通过全局单例注入的形式全局调用里面方法
            services.AddSignalR();

            //程序集依赖注入
            services.AddAssembly("Lucky.Project.Services");
            services.AddAspectCoreServices("Lucky.Project.Web");
            //泛型注入到DI里面
            services.AddScoped(typeof(IRepository <>), typeof(EfRepository <>));
            services.AddScoped <IAdminAuthService, AdminAuthService>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <IRegisterApplicationService, RegisterApplicationService>();
            //services.AddScoped<IhubContextRegister, hubContextRegister>();
            EnginContext.Initialize(new GeneralEngine(services.BuildServiceProvider()));


            services.AddTransient <UserInfoSyncjob>();                        // 这里使用瞬时依赖注入
            services.AddSingleton <ISchedulerFactory, StdSchedulerFactory>(); //注册ISchedulerFactory的实例。
            services.AddSingleton <QuartzStartup>();
            services.AddSingleton <IJobFactory, IOCJobFactory>();

            return(services.BuildAspectInjectorProvider());
        }
Esempio n. 13
0
 public static void AddEngineStartup(this IServiceCollection services)
 {
     EnginContext.Initialize(new GeneralEngine(services.BuildServiceProvider()));
 }