diff --git a/src/Microsoft.AspNet.Identity.EntityFramework/IdentityEntityFrameworkServices.cs b/src/Microsoft.AspNet.Identity.EntityFramework/IdentityEntityFrameworkServices.cs index c01ab1c1cb..50797c7aa5 100644 --- a/src/Microsoft.AspNet.Identity.EntityFramework/IdentityEntityFrameworkServices.cs +++ b/src/Microsoft.AspNet.Identity.EntityFramework/IdentityEntityFrameworkServices.cs @@ -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 /// public class IdentityEntityFrameworkServices { - public static IEnumerable 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; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs index 3e3736e4bd..83045c3318 100644 --- a/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs @@ -48,27 +48,25 @@ namespace Microsoft.Framework.DependencyInjection } services.Configure(identityConfig); } - var describe = new ServiceDescriber(identityConfig); - // Services used by identity - services.AddOptions(identityConfig); - services.AddDataProtection(identityConfig); - services.AddLogging(identityConfig); - services.TryAdd(describe.Singleton()); + services.AddOptions(); + services.AddDataProtection(); + services.AddLogging(); + services.TryAdd(ServiceDescriptor.Singleton()); // Identity services - services.TryAdd(describe.Transient, UserValidator>()); - services.TryAdd(describe.Transient, PasswordValidator>()); - services.TryAdd(describe.Transient, PasswordHasher>()); - services.TryAdd(describe.Transient()); - services.TryAdd(describe.Transient, RoleValidator>()); + services.TryAdd(ServiceDescriptor.Transient, UserValidator>()); + services.TryAdd(ServiceDescriptor.Transient, PasswordValidator>()); + services.TryAdd(ServiceDescriptor.Transient, PasswordHasher>()); + services.TryAdd(ServiceDescriptor.Transient()); + services.TryAdd(ServiceDescriptor.Transient, RoleValidator>()); // No interface for the error describer so we can add errors without rev'ing the interface - services.TryAdd(describe.Transient()); - services.TryAdd(describe.Scoped>()); - services.TryAdd(describe.Scoped, UserClaimsPrincipalFactory>()); - services.TryAdd(describe.Scoped, UserManager>()); - services.TryAdd(describe.Scoped, SignInManager>()); - services.TryAdd(describe.Scoped, RoleManager>()); + services.TryAdd(ServiceDescriptor.Transient()); + services.TryAdd(ServiceDescriptor.Scoped>()); + services.TryAdd(ServiceDescriptor.Scoped, UserClaimsPrincipalFactory>()); + services.TryAdd(ServiceDescriptor.Scoped, UserManager>()); + services.TryAdd(ServiceDescriptor.Scoped, SignInManager>()); + services.TryAdd(ServiceDescriptor.Scoped, RoleManager>()); if (configureOptions != null) { diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/RoleStoreTest.cs b/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/RoleStoreTest.cs index ea1f2dbf16..1ef2f46fd6 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/RoleStoreTest.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/RoleStoreTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/TestIdentityFactory.cs b/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/TestIdentityFactory.cs index 5e4a8ef137..4eaf724a1b 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/TestIdentityFactory.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/TestIdentityFactory.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.Test/DbUtil.cs b/test/Microsoft.AspNet.Identity.EntityFramework.Test/DbUtil.cs index 75b15d935c..59982a831c 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.Test/DbUtil.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.Test/DbUtil.cs @@ -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 diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.Test/DefaultPocoTest.cs b/test/Microsoft.AspNet.Identity.EntityFramework.Test/DefaultPocoTest.cs index c904870754..27c8a3eba6 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.Test/DefaultPocoTest.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.Test/DefaultPocoTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreTest.cs b/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreTest.cs index 689d927dac..02d42120d7 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreTest.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs b/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs index 2032a40778..d58f558fad 100644 --- a/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs b/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs index 823d0c639c..d95decf21b 100644 --- a/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs @@ -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; diff --git a/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs b/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs index 59836eb219..976d5b2b72 100644 --- a/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs @@ -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; diff --git a/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs b/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs index a129b28d58..ddbb38eabb 100644 --- a/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs @@ -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; diff --git a/test/Shared/UserManagerTestBase.cs b/test/Shared/UserManagerTestBase.cs index ba5d6228af..a72112e538 100644 --- a/test/Shared/UserManagerTestBase.cs +++ b/test/Shared/UserManagerTestBase.cs @@ -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;