Refactored AbpFeatureValueStore.
This commit is contained in:
Родитель
cab121b66d
Коммит
4747ecf434
|
@ -5,20 +5,15 @@ using Abp.Application.Features;
|
|||
using Abp.Collections.Extensions;
|
||||
using Abp.Domain.Repositories;
|
||||
using Abp.Domain.Services;
|
||||
using Abp.Domain.Uow;
|
||||
using Abp.Events.Bus.Entities;
|
||||
using Abp.Events.Bus.Handlers;
|
||||
using Abp.Runtime.Caching;
|
||||
|
||||
namespace Abp.Application.Editions
|
||||
{
|
||||
public abstract class AbpEditionManager :
|
||||
IDomainService,
|
||||
IEventHandler<EntityChangedEventData<Edition>>,
|
||||
IEventHandler<EntityChangedEventData<EditionFeatureSetting>>
|
||||
public abstract class AbpEditionManager : IDomainService
|
||||
{
|
||||
private readonly IAbpZeroFeatureValueStore _featureValueStore;
|
||||
public IQueryable<Edition> Editions { get { return EditionRepository.GetAll(); } }
|
||||
|
||||
public IQueryable<Edition> Editions => EditionRepository.GetAll();
|
||||
|
||||
public ICacheManager CacheManager { get; set; }
|
||||
|
||||
|
@ -93,22 +88,5 @@ namespace Abp.Application.Editions
|
|||
{
|
||||
return EditionRepository.DeleteAsync(edition);
|
||||
}
|
||||
|
||||
//TODO: Should move cache invalidation code to AbpFeatureValueStore
|
||||
|
||||
public virtual void HandleEvent(EntityChangedEventData<EditionFeatureSetting> eventData)
|
||||
{
|
||||
CacheManager.GetEditionFeatureCache().Remove(eventData.Entity.EditionId);
|
||||
}
|
||||
|
||||
public virtual void HandleEvent(EntityChangedEventData<Edition> eventData)
|
||||
{
|
||||
if (eventData.Entity.IsTransient())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CacheManager.GetEditionFeatureCache().Remove(eventData.Entity.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
using System.Threading.Tasks;
|
||||
using Abp.Application.Editions;
|
||||
using Abp.Authorization.Roles;
|
||||
using Abp.Authorization.Users;
|
||||
using Abp.Collections.Extensions;
|
||||
using Abp.Dependency;
|
||||
using Abp.Domain.Repositories;
|
||||
using Abp.Domain.Uow;
|
||||
using Abp.Events.Bus.Entities;
|
||||
using Abp.Events.Bus.Handlers;
|
||||
using Abp.MultiTenancy;
|
||||
using Abp.Runtime.Caching;
|
||||
|
||||
|
@ -14,9 +15,13 @@ namespace Abp.Application.Features
|
|||
/// <summary>
|
||||
/// Implements <see cref="IFeatureValueStore"/>.
|
||||
/// </summary>
|
||||
public abstract class AbpFeatureValueStore<TTenant, TRole, TUser> : IAbpZeroFeatureValueStore, ITransientDependency
|
||||
public abstract class AbpFeatureValueStore<TTenant, TUser> :
|
||||
IAbpZeroFeatureValueStore,
|
||||
ITransientDependency,
|
||||
IEventHandler<EntityChangedEventData<Edition>>,
|
||||
IEventHandler<EntityChangedEventData<EditionFeatureSetting>>
|
||||
|
||||
where TTenant : AbpTenant<TUser>
|
||||
where TRole : AbpRole<TUser>
|
||||
where TUser : AbpUser<TUser>
|
||||
{
|
||||
private readonly ICacheManager _cacheManager;
|
||||
|
@ -27,7 +32,7 @@ namespace Abp.Application.Features
|
|||
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AbpFeatureValueStore{TTenant, TRole, TUser}"/> class.
|
||||
/// Initializes a new instance of the <see cref="AbpFeatureValueStore{TTenant, TUser}"/> class.
|
||||
/// </summary>
|
||||
protected AbpFeatureValueStore(
|
||||
ICacheManager cacheManager,
|
||||
|
@ -166,5 +171,20 @@ namespace Abp.Application.Features
|
|||
|
||||
return newCacheItem;
|
||||
}
|
||||
|
||||
public virtual void HandleEvent(EntityChangedEventData<EditionFeatureSetting> eventData)
|
||||
{
|
||||
_cacheManager.GetEditionFeatureCache().Remove(eventData.Entity.EditionId);
|
||||
}
|
||||
|
||||
public virtual void HandleEvent(EntityChangedEventData<Edition> eventData)
|
||||
{
|
||||
if (eventData.Entity.IsTransient())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_cacheManager.GetEditionFeatureCache().Remove(eventData.Entity.Id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,12 +4,11 @@ using Abp.Domain.Uow;
|
|||
using Abp.MultiTenancy;
|
||||
using Abp.Runtime.Caching;
|
||||
using Abp.Zero.SampleApp.MultiTenancy;
|
||||
using Abp.Zero.SampleApp.Roles;
|
||||
using Abp.Zero.SampleApp.Users;
|
||||
|
||||
namespace Abp.Zero.SampleApp.Features
|
||||
{
|
||||
public class FeatureValueStore : AbpFeatureValueStore<Tenant, Role, User>
|
||||
public class FeatureValueStore : AbpFeatureValueStore<Tenant, User>
|
||||
{
|
||||
public FeatureValueStore(ICacheManager cacheManager,
|
||||
IRepository<TenantFeatureSetting, long> tenantFeatureRepository,
|
||||
|
|
Загрузка…
Ссылка в новой задаче