Browse Source

Comment updates.

pull/272/head
Halil İbrahim Kalkan 9 years ago
parent
commit
3ca1cbb6fc
  1. 8
      src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs
  2. 6
      src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs

8
src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs

@ -11,7 +11,7 @@ namespace Microsoft.Extensions.DependencyInjection
{ {
public static IServiceCollection AddDefaultRepository(this IServiceCollection services, Type entityType, Type repositoryImplementationType) public static IServiceCollection AddDefaultRepository(this IServiceCollection services, Type entityType, Type repositoryImplementationType)
{ {
//IRepository<TEntity> //IBasicRepository<TEntity>
var repositoryInterfaceWithoutPk = typeof(IBasicRepository<>).MakeGenericType(entityType); var repositoryInterfaceWithoutPk = typeof(IBasicRepository<>).MakeGenericType(entityType);
if (!repositoryInterfaceWithoutPk.IsAssignableFrom(repositoryImplementationType)) if (!repositoryInterfaceWithoutPk.IsAssignableFrom(repositoryImplementationType))
{ {
@ -20,7 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddTransient(repositoryInterfaceWithoutPk, repositoryImplementationType); services.TryAddTransient(repositoryInterfaceWithoutPk, repositoryImplementationType);
//IQueryableRepository<TEntity> //IRepository<TEntity>
var queryableRepositoryInterfaceWithPk = typeof(IRepository<>).MakeGenericType(entityType); var queryableRepositoryInterfaceWithPk = typeof(IRepository<>).MakeGenericType(entityType);
if (repositoryInterfaceWithoutPk.IsAssignableFrom(repositoryImplementationType)) if (repositoryInterfaceWithoutPk.IsAssignableFrom(repositoryImplementationType))
{ {
@ -31,14 +31,14 @@ namespace Microsoft.Extensions.DependencyInjection
if (primaryKeyType != null) if (primaryKeyType != null)
{ {
//IRepository<TEntity, TKey> //IBasicRepository<TEntity, TKey>
var repositoryInterface = typeof(IBasicRepository<,>).MakeGenericType(entityType, primaryKeyType); var repositoryInterface = typeof(IBasicRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (repositoryInterface.GetTypeInfo().IsAssignableFrom(repositoryImplementationType)) if (repositoryInterface.GetTypeInfo().IsAssignableFrom(repositoryImplementationType))
{ {
services.TryAddTransient(repositoryInterface, repositoryImplementationType); services.TryAddTransient(repositoryInterface, repositoryImplementationType);
} }
//IQueryableRepository<TEntity, TKey> //IRepository<TEntity, TKey>
var queryableRepositoryInterface = typeof(IRepository<,>).MakeGenericType(entityType, primaryKeyType); var queryableRepositoryInterface = typeof(IRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (queryableRepositoryInterface.GetTypeInfo().IsAssignableFrom(repositoryImplementationType)) if (queryableRepositoryInterface.GetTypeInfo().IsAssignableFrom(repositoryImplementationType))
{ {

6
src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryRegistrarBase.cs

@ -42,7 +42,7 @@ namespace Volo.Abp.Domain.Repositories
} }
} }
protected void RegisterDefaultRepository(IServiceCollection services, Type entityType) protected virtual void RegisterDefaultRepository(IServiceCollection services, Type entityType)
{ {
services.AddDefaultRepository( services.AddDefaultRepository(
entityType, entityType,
@ -50,7 +50,7 @@ namespace Volo.Abp.Domain.Repositories
); );
} }
private Type GetDefaultRepositoryImplementationType(Type entityType) protected virtual Type GetDefaultRepositoryImplementationType(Type entityType)
{ {
var primaryKeyType = EntityHelper.FindPrimaryKeyType(entityType); var primaryKeyType = EntityHelper.FindPrimaryKeyType(entityType);
@ -66,7 +66,7 @@ namespace Volo.Abp.Domain.Repositories
: GetRepositoryType(Options.DefaultRepositoryDbContextType, entityType, primaryKeyType); : GetRepositoryType(Options.DefaultRepositoryDbContextType, entityType, primaryKeyType);
} }
public bool ShouldRegisterDefaultRepositoryFor(Type entityType) protected virtual bool ShouldRegisterDefaultRepositoryFor(Type entityType)
{ {
if (!Options.RegisterDefaultRepositories) if (!Options.RegisterDefaultRepositories)
{ {

Loading…
Cancel
Save