AddEntity -> AddEntityFramework
AddSecurity -> AddHttpSignIn
This commit is contained in:
Hao Kung 2014-05-16 11:13:56 -07:00
Родитель 7bf68e0e58
Коммит ffc9822746
4 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -26,6 +26,7 @@ namespace Microsoft.AspNet.Identity
return builder; return builder;
} }
// todo: remove
public static IdentityBuilder<TUser, IdentityRole> AddEntity<TUser, TContext>(this IdentityBuilder<TUser, IdentityRole> builder) public static IdentityBuilder<TUser, IdentityRole> AddEntity<TUser, TContext>(this IdentityBuilder<TUser, IdentityRole> builder)
where TUser : User where TContext : DbContext where TUser : User where TContext : DbContext
{ {
@ -35,5 +36,14 @@ namespace Microsoft.AspNet.Identity
return builder; return builder;
} }
// todo: add overloads
public static IdentityBuilder<TUser, IdentityRole> AddEntityFramework<TUser, TContext>(this IdentityBuilder<TUser, IdentityRole> builder)
where TUser : User where TContext : DbContext
{
builder.Services.AddScoped<IUserStore<TUser>, UserStore<TUser, TContext>>();
builder.Services.AddScoped<UserManager<TUser>>();
builder.Services.AddScoped<TContext>();
return builder;
}
} }
} }

Просмотреть файл

@ -8,11 +8,19 @@ namespace Microsoft.AspNet.Identity
{ {
public static class IdentityBuilderExtensions public static class IdentityBuilderExtensions
{ {
// TODO: remove
public static IdentityBuilder<TUser, IdentityRole> AddSecurity<TUser>(this IdentityBuilder<TUser, IdentityRole> builder) public static IdentityBuilder<TUser, IdentityRole> AddSecurity<TUser>(this IdentityBuilder<TUser, IdentityRole> builder)
where TUser : class where TUser : class
{ {
builder.Services.AddScoped<SignInManager<TUser>>(); builder.Services.AddScoped<SignInManager<TUser>>();
return builder; return builder;
} }
public static IdentityBuilder<TUser, IdentityRole> AddHttpSignIn<TUser>(this IdentityBuilder<TUser, IdentityRole> builder)
where TUser : class
{
builder.Services.AddScoped<SignInManager<TUser>>();
return builder;
}
} }
} }

Просмотреть файл

@ -7,6 +7,7 @@ namespace Microsoft.Framework.DependencyInjection
{ {
public static class SecurityServiceCollectionExtensions public static class SecurityServiceCollectionExtensions
{ {
// todo: remove?
public static ServiceCollection AddSecurity<TUser>(this ServiceCollection services) public static ServiceCollection AddSecurity<TUser>(this ServiceCollection services)
where TUser : class where TUser : class
{ {

Просмотреть файл

@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Identity.Security.Test
services.AddIdentity<ApplicationUser, IdentityRole>(s => services.AddIdentity<ApplicationUser, IdentityRole>(s =>
{ {
s.AddInMemory(); s.AddInMemory();
}).AddSecurity<ApplicationUser>(); }).AddHttpSignIn<ApplicationUser>();
}); });
// Act // Act