コード例 #1
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddDbContext <AwesomePotatoContext>(x => x.UseSqlServer(Configuration.GetConnectionString("default")));
     IdentityConfiguration.ConfigureServices(services, Configuration);
     services.AddAutoMapper(typeof(Startup));
     services.AddScoped <IErrorLogDataService, ErrorLogDataService>();
     services.AddScoped <IUserManagementService, UserManagementService>();
     services.AddControllers();
 }
コード例 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationContext>(x => x.UseSqlServer(Configuration.GetConnectionString("default")));

            IdentityConfiguration.ConfigureServices(services, Configuration);
            services.AddScoped(typeof(UserManagementService), typeof(UserManagementService));

            services.AddControllers();
        }
コード例 #3
0
        protected static void ConfigureIdentity()
        {
            Services.AddSingleton(IdentityContextOptions);
            //IdentityConfiguration.ConfigureTesting(services, configuration);

            //Services.AddSingleton(_ => new TokenValidationParameters());
            //Services.AddDbContext<AppIdentityDbContext>();
            //Services.AddIdentity<ApplicationUser, IdentityRole>()
            //  .AddEntityFrameworkStores<AppIdentityDbContext>()
            //  .AddDefaultTokenProviders();
            // Services.AddScoped<IIdentityService, IdentityService>();
            Services.AddScoped <UserManager <ApplicationUser>, UserManager <ApplicationUser> >();
            Services.AddScoped <SignInManager <ApplicationUser>, SignInManager <ApplicationUser> >();
            Services.AddScoped <IAuthorizationService, DefaultAuthorizationService>();
            Services.AddScoped <IAuthorizationPolicyProvider, DefaultAuthorizationPolicyProvider>();
            Services.AddScoped <IAuthorizationHandlerProvider, DefaultAuthorizationHandlerProvider>();
            Services.AddScoped <IAuthorizationHandlerContextFactory, DefaultAuthorizationHandlerContextFactory>();
            Services.AddScoped <IAuthorizationEvaluator, DefaultAuthorizationEvaluator>();
            Services.AddSingleton <IScopedParameters>(_scopedParameters);
            IdentityConfiguration.ConfigureServices(Services, AppSetting);

            //await signInManager.SignInAsync(
            //    await Resolve<UserManager<ApplicationUser>>().FindByIdAsync(adminId), false);
        }