React to DI changes
This commit is contained in:
parent
3aaa628365
commit
d5b29d7e23
|
|
@ -2,10 +2,9 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
|
||||
namespace Microsoft.AspNet.Identity
|
||||
{
|
||||
|
|
@ -14,17 +13,8 @@ namespace Microsoft.AspNet.Identity
|
|||
/// </summary>
|
||||
public class IdentityEntityFrameworkServices
|
||||
{
|
||||
public static IEnumerable<IServiceDescriptor> GetDefaultServices(Type userType, Type roleType, Type contextType, Type keyType = null, IConfiguration config = null)
|
||||
public static IServiceCollection GetDefaultServices(Type userType, Type roleType, Type contextType, Type keyType = null, IConfiguration config = null)
|
||||
{
|
||||
ServiceDescriber describe;
|
||||
if (config == null)
|
||||
{
|
||||
describe = new ServiceDescriber();
|
||||
}
|
||||
else
|
||||
{
|
||||
describe = new ServiceDescriber(config);
|
||||
}
|
||||
Type userStoreType;
|
||||
Type roleStoreType;
|
||||
if (keyType != null)
|
||||
|
|
@ -38,12 +28,14 @@ namespace Microsoft.AspNet.Identity
|
|||
roleStoreType = typeof(RoleStore<,>).MakeGenericType(roleType, contextType);
|
||||
}
|
||||
|
||||
yield return describe.Scoped(
|
||||
var services = new ServiceCollection();
|
||||
services.AddScoped(
|
||||
typeof(IUserStore<>).MakeGenericType(userType),
|
||||
userStoreType);
|
||||
yield return describe.Scoped(
|
||||
services.AddScoped(
|
||||
typeof(IRoleStore<>).MakeGenericType(roleType),
|
||||
roleStoreType);
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,27 +48,25 @@ namespace Microsoft.Framework.DependencyInjection
|
|||
}
|
||||
services.Configure<IdentityOptions>(identityConfig);
|
||||
}
|
||||
var describe = new ServiceDescriber(identityConfig);
|
||||
|
||||
// Services used by identity
|
||||
services.AddOptions(identityConfig);
|
||||
services.AddDataProtection(identityConfig);
|
||||
services.AddLogging(identityConfig);
|
||||
services.TryAdd(describe.Singleton<IHttpContextAccessor, HttpContextAccessor>());
|
||||
services.AddOptions();
|
||||
services.AddDataProtection();
|
||||
services.AddLogging();
|
||||
services.TryAdd(ServiceDescriptor.Singleton<IHttpContextAccessor, HttpContextAccessor>());
|
||||
|
||||
// Identity services
|
||||
services.TryAdd(describe.Transient<IUserValidator<TUser>, UserValidator<TUser>>());
|
||||
services.TryAdd(describe.Transient<IPasswordValidator<TUser>, PasswordValidator<TUser>>());
|
||||
services.TryAdd(describe.Transient<IPasswordHasher<TUser>, PasswordHasher<TUser>>());
|
||||
services.TryAdd(describe.Transient<ILookupNormalizer, UpperInvariantLookupNormalizer>());
|
||||
services.TryAdd(describe.Transient<IRoleValidator<TRole>, RoleValidator<TRole>>());
|
||||
services.TryAdd(ServiceDescriptor.Transient<IUserValidator<TUser>, UserValidator<TUser>>());
|
||||
services.TryAdd(ServiceDescriptor.Transient<IPasswordValidator<TUser>, PasswordValidator<TUser>>());
|
||||
services.TryAdd(ServiceDescriptor.Transient<IPasswordHasher<TUser>, PasswordHasher<TUser>>());
|
||||
services.TryAdd(ServiceDescriptor.Transient<ILookupNormalizer, UpperInvariantLookupNormalizer>());
|
||||
services.TryAdd(ServiceDescriptor.Transient<IRoleValidator<TRole>, RoleValidator<TRole>>());
|
||||
// No interface for the error describer so we can add errors without rev'ing the interface
|
||||
services.TryAdd(describe.Transient<IdentityErrorDescriber, IdentityErrorDescriber>());
|
||||
services.TryAdd(describe.Scoped<ISecurityStampValidator, SecurityStampValidator<TUser>>());
|
||||
services.TryAdd(describe.Scoped<IUserClaimsPrincipalFactory<TUser>, UserClaimsPrincipalFactory<TUser, TRole>>());
|
||||
services.TryAdd(describe.Scoped<UserManager<TUser>, UserManager<TUser>>());
|
||||
services.TryAdd(describe.Scoped<SignInManager<TUser>, SignInManager<TUser>>());
|
||||
services.TryAdd(describe.Scoped<RoleManager<TRole>, RoleManager<TRole>>());
|
||||
services.TryAdd(ServiceDescriptor.Transient<IdentityErrorDescriber, IdentityErrorDescriber>());
|
||||
services.TryAdd(ServiceDescriptor.Scoped<ISecurityStampValidator, SecurityStampValidator<TUser>>());
|
||||
services.TryAdd(ServiceDescriptor.Scoped<IUserClaimsPrincipalFactory<TUser>, UserClaimsPrincipalFactory<TUser, TRole>>());
|
||||
services.TryAdd(ServiceDescriptor.Scoped<UserManager<TUser>, UserManager<TUser>>());
|
||||
services.TryAdd(ServiceDescriptor.Scoped<SignInManager<TUser>, SignInManager<TUser>>());
|
||||
services.TryAdd(ServiceDescriptor.Scoped<RoleManager<TRole>, RoleManager<TRole>>());
|
||||
|
||||
if (configureOptions != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ using System;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Identity.Test;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Identity.EntityFramework.InMemory.Test
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
|
||||
namespace Microsoft.AspNet.Identity.EntityFramework.InMemory.Test
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Identity.EntityFramework.Test
|
||||
|
|
|
|||
|
|
@ -6,10 +6,8 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Identity.Test;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Xunit;
|
||||
using Microsoft.Framework.Runtime.Infrastructure;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Identity.EntityFramework.Test
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,18 +3,13 @@
|
|||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Identity.Test;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Microsoft.AspNet.DataProtection;
|
||||
using Xunit;
|
||||
using Microsoft.Framework.Runtime.Infrastructure;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Identity.EntityFramework.Test
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Identity.Test
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using System.Security.Claims;
|
|||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Microsoft.Framework.Runtime.Infrastructure;
|
||||
using Xunit;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ using Microsoft.AspNet.Hosting;
|
|||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Authentication;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Microsoft.Framework.OptionsModel;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using System.Security.Claims;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Testing;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||
using Microsoft.Framework.Logging;
|
||||
using Xunit;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue