示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSignalR();

            String connection = GlobalStrings.GetConnectionStringName();

            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString(connection)));
            services.AddDefaultIdentity <IdentityUser>().AddEntityFrameworkStores <ApplicationDbContext>();

            services.AddDbContext <ChatDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString(connection)));

            services.Configure <IdentityOptions>(o =>
            {
                o.SignIn.RequireConfirmedAccount  = false;
                o.Password.RequireDigit           = false;
                o.Password.RequiredLength         = 5;
                o.Password.RequireLowercase       = false;
                o.Password.RequireNonAlphanumeric = false;
                o.Password.RequireUppercase       = false;
            });

            IMvcBuilder mvc      = services.AddControllersWithViews();
            IMvcBuilder mvcpages = services.AddRazorPages();

            services.AddSingleton <InviteManager>();

            services.AddSingleton <GameSRIDS>();
            services.AddSingleton <MesSRIDS>();

            services.AddScoped <SignalRMessenger>();
            services.AddDatabaseDeveloperPageExceptionFilter();

#if DEBUG
            mvc.AddRazorRuntimeCompilation();
            mvcpages.AddRazorRuntimeCompilation();
#endif
        }