maliming 4 years ago
parent
commit
3fa985e923
  1. 14
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapper.cs
  2. 14
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapperContext.cs
  3. 17
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithoutCacheItem.cs

14
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapper.cs

@ -2,23 +2,23 @@
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
namespace Volo.Abp.Domain.Entities.Caching; namespace Volo.Abp.Domain.Entities.Caching;
public class EntityCacheWithObjectMapper<TEntity, TEntityCacheItem, TKey> : public class EntityCacheWithObjectMapper<TEntity, TEntityCacheItem, TKey> :
EntityCacheBase<TEntity, TEntityCacheItem, TKey> EntityCacheBase<TEntity, TEntityCacheItem, TKey>
where TEntity : Entity<TKey> where TEntity : Entity<TKey>
where TEntityCacheItem : class where TEntityCacheItem : class
{ {
protected IObjectMapper ObjectMapper { get; } protected IObjectMapper ObjectMapper { get; }
public EntityCacheWithObjectMapper( public EntityCacheWithObjectMapper(
IReadOnlyRepository<TEntity, TKey> repository, IReadOnlyRepository<TEntity, TKey> repository,
IDistributedCache<TEntityCacheItem, TKey> cache, IDistributedCache<TEntityCacheItem, TKey> cache,
IUnitOfWorkManager unitOfWorkManager,
IObjectMapper objectMapper) IObjectMapper objectMapper)
: base( : base(repository, cache, unitOfWorkManager)
repository,
cache)
{ {
ObjectMapper = objectMapper; ObjectMapper = objectMapper;
} }
@ -29,7 +29,7 @@ public class EntityCacheWithObjectMapper<TEntity, TEntityCacheItem, TKey> :
{ {
return null; return null;
} }
if (typeof(TEntity) == typeof(TEntityCacheItem)) if (typeof(TEntity) == typeof(TEntityCacheItem))
{ {
return entity.As<TEntityCacheItem>(); return entity.As<TEntityCacheItem>();
@ -37,4 +37,4 @@ public class EntityCacheWithObjectMapper<TEntity, TEntityCacheItem, TKey> :
return ObjectMapper.Map<TEntity, TEntityCacheItem>(entity); return ObjectMapper.Map<TEntity, TEntityCacheItem>(entity);
} }
} }

14
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithObjectMapperContext.cs

@ -1,22 +1,22 @@
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
namespace Volo.Abp.Domain.Entities.Caching; namespace Volo.Abp.Domain.Entities.Caching;
public class EntityCacheWithObjectMapperContext<TObjectMapperContext, TEntity, TEntityCacheItem, TKey> : public class EntityCacheWithObjectMapperContext<TObjectMapperContext, TEntity, TEntityCacheItem, TKey> :
EntityCacheWithObjectMapper<TEntity, TEntityCacheItem, TKey> EntityCacheWithObjectMapper<TEntity, TEntityCacheItem, TKey>
where TEntity : Entity<TKey> where TEntity : Entity<TKey>
where TEntityCacheItem : class where TEntityCacheItem : class
{ {
public EntityCacheWithObjectMapperContext( public EntityCacheWithObjectMapperContext(
IReadOnlyRepository<TEntity, TKey> repository, IReadOnlyRepository<TEntity, TKey> repository,
IDistributedCache<TEntityCacheItem, TKey> cache, IDistributedCache<TEntityCacheItem, TKey> cache,
IObjectMapper<TObjectMapperContext> objectMapper) // Intentionally injected with TContext IUnitOfWorkManager unitOfWorkManager,
: base( IObjectMapper objectMapper)// Intentionally injected with TContext
repository, : base(repository, cache, unitOfWorkManager, objectMapper)
cache,
objectMapper)
{ {
} }
} }

17
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheWithoutCacheItem.cs

@ -1,24 +1,25 @@
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
namespace Volo.Abp.Domain.Entities.Caching; namespace Volo.Abp.Domain.Entities.Caching;
public class EntityCacheWithoutCacheItem<TEntity, TKey> : public class EntityCacheWithoutCacheItem<TEntity, TKey> :
EntityCacheBase<TEntity, TEntity, TKey> EntityCacheBase<TEntity, TEntity, TKey>
where TEntity : Entity<TKey> where TEntity : Entity<TKey>
{ {
public EntityCacheWithoutCacheItem( public EntityCacheWithoutCacheItem(
IReadOnlyRepository<TEntity, TKey> repository, IReadOnlyRepository<TEntity, TKey> repository,
IDistributedCache<TEntity, TKey> cache) IDistributedCache<TEntity, TKey> cache,
: base( IUnitOfWorkManager unitOfWorkManager)
repository, : base(repository, cache, unitOfWorkManager)
cache)
{ {
} }
protected override TEntity MapToCacheItem(TEntity entity) protected override TEntity MapToCacheItem(TEntity entity)
{ {
return entity; return entity;
} }
}
}

Loading…
Cancel
Save