Browse Source

Update the ReplaceDefault*Entity() methods to register the MongoDB stores as singletons

pull/2546/head 7.6.1
Kévin Chalet 1 month ago
parent
commit
9167ed835b
  1. 8
      src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs
  2. 8
      test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbBuilderTests.cs

8
src/OpenIddict.MongoDb/OpenIddictMongoDbBuilder.cs

@ -57,7 +57,7 @@ public sealed class OpenIddictMongoDbBuilder
Services.Replace(ServiceDescriptor.Scoped<IOpenIddictApplicationManager>(static provider => Services.Replace(ServiceDescriptor.Scoped<IOpenIddictApplicationManager>(static provider =>
provider.GetRequiredService<OpenIddictApplicationManager<TApplication>>())); provider.GetRequiredService<OpenIddictApplicationManager<TApplication>>()));
Services.Replace(ServiceDescriptor.Scoped< Services.Replace(ServiceDescriptor.Singleton<
IOpenIddictApplicationStore<TApplication>, OpenIddictMongoDbApplicationStore<TApplication>>()); IOpenIddictApplicationStore<TApplication>, OpenIddictMongoDbApplicationStore<TApplication>>());
return this; return this;
@ -74,7 +74,7 @@ public sealed class OpenIddictMongoDbBuilder
Services.Replace(ServiceDescriptor.Scoped<IOpenIddictAuthorizationManager>(static provider => Services.Replace(ServiceDescriptor.Scoped<IOpenIddictAuthorizationManager>(static provider =>
provider.GetRequiredService<OpenIddictAuthorizationManager<TAuthorization>>())); provider.GetRequiredService<OpenIddictAuthorizationManager<TAuthorization>>()));
Services.Replace(ServiceDescriptor.Scoped< Services.Replace(ServiceDescriptor.Singleton<
IOpenIddictAuthorizationStore<TAuthorization>, OpenIddictMongoDbAuthorizationStore<TAuthorization>>()); IOpenIddictAuthorizationStore<TAuthorization>, OpenIddictMongoDbAuthorizationStore<TAuthorization>>());
return this; return this;
@ -91,7 +91,7 @@ public sealed class OpenIddictMongoDbBuilder
Services.Replace(ServiceDescriptor.Scoped<IOpenIddictScopeManager>(static provider => Services.Replace(ServiceDescriptor.Scoped<IOpenIddictScopeManager>(static provider =>
provider.GetRequiredService<OpenIddictScopeManager<TScope>>())); provider.GetRequiredService<OpenIddictScopeManager<TScope>>()));
Services.Replace(ServiceDescriptor.Scoped< Services.Replace(ServiceDescriptor.Singleton<
IOpenIddictScopeStore<TScope>, OpenIddictMongoDbScopeStore<TScope>>()); IOpenIddictScopeStore<TScope>, OpenIddictMongoDbScopeStore<TScope>>());
return this; return this;
@ -108,7 +108,7 @@ public sealed class OpenIddictMongoDbBuilder
Services.Replace(ServiceDescriptor.Scoped<IOpenIddictTokenManager>(static provider => Services.Replace(ServiceDescriptor.Scoped<IOpenIddictTokenManager>(static provider =>
provider.GetRequiredService<OpenIddictTokenManager<TToken>>())); provider.GetRequiredService<OpenIddictTokenManager<TToken>>()));
Services.Replace(ServiceDescriptor.Scoped< Services.Replace(ServiceDescriptor.Singleton<
IOpenIddictTokenStore<TToken>, OpenIddictMongoDbTokenStore<TToken>>()); IOpenIddictTokenStore<TToken>, OpenIddictMongoDbTokenStore<TToken>>());
return this; return this;

8
test/OpenIddict.MongoDb.Tests/OpenIddictMongoDbBuilderTests.cs

@ -39,7 +39,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictApplicationStore<CustomApplication>) && service.ServiceType == typeof(IOpenIddictApplicationStore<CustomApplication>) &&
service.ImplementationType == typeof(OpenIddictMongoDbApplicationStore<CustomApplication>)); service.ImplementationType == typeof(OpenIddictMongoDbApplicationStore<CustomApplication>));
} }
@ -56,7 +56,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictAuthorizationStore<CustomAuthorization>) && service.ServiceType == typeof(IOpenIddictAuthorizationStore<CustomAuthorization>) &&
service.ImplementationType == typeof(OpenIddictMongoDbAuthorizationStore<CustomAuthorization>)); service.ImplementationType == typeof(OpenIddictMongoDbAuthorizationStore<CustomAuthorization>));
} }
@ -73,7 +73,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictScopeStore<CustomScope>) && service.ServiceType == typeof(IOpenIddictScopeStore<CustomScope>) &&
service.ImplementationType == typeof(OpenIddictMongoDbScopeStore<CustomScope>)); service.ImplementationType == typeof(OpenIddictMongoDbScopeStore<CustomScope>));
} }
@ -90,7 +90,7 @@ public class OpenIddictMongoDbBuilderTests
// Assert // Assert
Assert.Contains(services, service => Assert.Contains(services, service =>
service.Lifetime == ServiceLifetime.Scoped && service.Lifetime is ServiceLifetime.Singleton &&
service.ServiceType == typeof(IOpenIddictTokenStore<CustomToken>) && service.ServiceType == typeof(IOpenIddictTokenStore<CustomToken>) &&
service.ImplementationType == typeof(OpenIddictMongoDbTokenStore<CustomToken>)); service.ImplementationType == typeof(OpenIddictMongoDbTokenStore<CustomToken>));
} }

Loading…
Cancel
Save