Browse Source
Change some code base on review cmment.
pull/17421/head
maliming
3 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
3 changed files with
8 additions and
5 deletions
-
framework/src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs
-
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs
-
framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs
|
|
|
@ -84,11 +84,11 @@ public static class ServiceCollectionRepositoryExtensions |
|
|
|
bool replaceExisting, |
|
|
|
bool isReadOnlyRepository = false) |
|
|
|
{ |
|
|
|
var descriptor = ServiceDescriptor.Transient(serviceType, implementationType); |
|
|
|
ServiceDescriptor descriptor; |
|
|
|
|
|
|
|
if (isReadOnlyRepository) |
|
|
|
{ |
|
|
|
services.AddTransient(implementationType); |
|
|
|
services.TryAddTransient(implementationType); |
|
|
|
descriptor = ServiceDescriptor.Transient(serviceType, provider => |
|
|
|
{ |
|
|
|
var repository = provider.GetRequiredService(implementationType); |
|
|
|
@ -96,6 +96,10 @@ public static class ServiceCollectionRepositoryExtensions |
|
|
|
return repository; |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
descriptor = ServiceDescriptor.Transient(serviceType, implementationType); |
|
|
|
} |
|
|
|
|
|
|
|
if (replaceExisting) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -34,8 +34,7 @@ public abstract class BasicRepositoryBase<TEntity> : |
|
|
|
|
|
|
|
public ICancellationTokenProvider CancellationTokenProvider => LazyServiceProvider.LazyGetService<ICancellationTokenProvider>(NullCancellationTokenProvider.Instance); |
|
|
|
|
|
|
|
|
|
|
|
public bool IsReadOnly { get; set; } = false; |
|
|
|
public bool IsReadOnly { get; protected set; } |
|
|
|
|
|
|
|
protected BasicRepositoryBase() |
|
|
|
{ |
|
|
|
|
|
|
|
@ -407,7 +407,7 @@ public class RepositoryRegistration_Tests |
|
|
|
|
|
|
|
public class MyTestAggregateRootWithDefaultPkEmptyRepository : IMyTestAggregateRootWithDefaultPkEmptyRepository |
|
|
|
{ |
|
|
|
public bool IsReadOnly { get; set; } = false; |
|
|
|
public bool IsReadOnly { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
public class TestDbContextRegistrationOptions : AbpCommonDbContextRegistrationOptions |
|
|
|
|