From a9ffe66032cd9c3d5a24c06c47b9fdd3d59e01ca Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Mon, 14 Oct 2019 22:44:22 +0300 Subject: [PATCH 01/17] closes #1900 Implementation of IDistributedCache --- .../Volo/Abp/Caching/AbpCachingModule.cs | 1 + .../Volo/Abp/Caching/DistributedCache.cs | 323 ++++++++++++++++++ .../Volo/Abp/Caching/IDistributedCache.cs | 144 ++++++++ .../Abp/Caching/DistributedCache_Tests.cs | 145 ++++++++ .../Volo/Abp/Caching/PersonCacheItem.cs | 7 + 5 files changed, 620 insertions(+) diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs index 48d55cc0d5..0502cd8d81 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs @@ -21,6 +21,7 @@ namespace Volo.Abp.Caching context.Services.AddDistributedMemoryCache(); context.Services.AddSingleton(typeof(IDistributedCache<>), typeof(DistributedCache<>)); + context.Services.AddSingleton(typeof(IDistributedCache<,>), typeof(DistributedCache<,>)); context.Services.Configure(cacheOptions => { diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs index caa51aeac1..654e60f323 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs @@ -439,4 +439,327 @@ namespace Volo.Abp.Caching DefaultCacheOptions = GetDefaultCacheEntryOptions(); } } + /// + /// Represents a distributed cache of type. + /// Uses a generic cache key type of type. + /// + /// The type of cache item being cached. + /// The type of cache key being used. + public class DistributedCache : IDistributedCache + where TCacheItem : class + { + public ILogger> Logger { get; set; } + + protected string CacheName { get; set; } + + protected bool IgnoreMultiTenancy { get; set; } + + protected IDistributedCache Cache { get; } + + protected ICancellationTokenProvider CancellationTokenProvider { get; } + + protected IDistributedCacheSerializer Serializer { get; } + + protected ICurrentTenant CurrentTenant { get; } + + protected SemaphoreSlim SyncSemaphore { get; } + + protected DistributedCacheEntryOptions DefaultCacheOptions; + + private readonly CacheOptions _cacheOption; + + private readonly DistributedCacheOptions _distributedCacheOption; + + public DistributedCache( + IOptions cacheOption, + IOptions distributedCacheOption, + IDistributedCache cache, + ICancellationTokenProvider cancellationTokenProvider, + IDistributedCacheSerializer serializer, + ICurrentTenant currentTenant) + { + _distributedCacheOption = distributedCacheOption.Value; + _cacheOption = cacheOption.Value; + Cache = cache; + CancellationTokenProvider = cancellationTokenProvider; + Logger = NullLogger>.Instance; + Serializer = serializer; + CurrentTenant = currentTenant; + + SyncSemaphore = new SemaphoreSlim(1, 1); + + SetDefaultOptions(); + } + protected virtual string NormalizeKey(string key) + { + var normalizedKey = "c:" + CacheName + ",k:" + _cacheOption.KeyPrefix + key; + + if (!IgnoreMultiTenancy && CurrentTenant.Id.HasValue) + { + normalizedKey = "t:" + CurrentTenant.Id.Value + "," + normalizedKey; + } + + return normalizedKey; + } + + protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions() + { + foreach (var configure in _cacheOption.CacheConfigurators) + { + var options = configure.Invoke(CacheName); + if (options != null) + { + return options; + } + } + return _cacheOption.GlobalCacheEntryOptions; + } + + protected virtual void SetDefaultOptions() + { + CacheName = CacheNameAttribute.GetCacheName(typeof(TCacheItem)); + + //IgnoreMultiTenancy + IgnoreMultiTenancy = typeof(TCacheItem).IsDefined(typeof(IgnoreMultiTenancyAttribute), true); + + //Configure default cache entry options + DefaultCacheOptions = GetDefaultCacheEntryOptions(); + } + public virtual TCacheItem Get(TCacheKey key, bool? hideErrors = null) + { + hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; + + byte[] cachedBytes; + + try + { + cachedBytes = Cache.Get(NormalizeKey(key?.ToString())); + } + catch (Exception ex) + { + if (hideErrors == true) + { + Logger.LogException(ex, LogLevel.Warning); + return null; + } + + throw; + } + + if (cachedBytes == null) + { + return null; + } + + return Serializer.Deserialize(cachedBytes); + } + + public virtual async Task GetAsync(TCacheKey key, bool? hideErrors = null, CancellationToken token = default) + { + hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; + + byte[] cachedBytes; + + try + { + cachedBytes = await Cache.GetAsync( + NormalizeKey(key.ToString()), + CancellationTokenProvider.FallbackToProvider(token) + ); + } + catch (Exception ex) + { + if (hideErrors == true) + { + Logger.LogException(ex, LogLevel.Warning); + return null; + } + + throw; + } + + if (cachedBytes == null) + { + return null; + } + + return Serializer.Deserialize(cachedBytes); + } + + public virtual TCacheItem GetOrAdd(TCacheKey key, Func factory, Func optionsFactory = null, bool? hideErrors = null) + { + var value = Get(key, hideErrors); + if (value != null) + { + return value; + } + + using (SyncSemaphore.Lock()) + { + value = Get(key, hideErrors); + if (value != null) + { + return value; + } + + value = factory(); + Set(key, value, optionsFactory?.Invoke(), hideErrors); + } + + return value; + } + + public virtual async Task GetOrAddAsync(TCacheKey key, Func> factory, Func optionsFactory = null, bool? hideErrors = null, CancellationToken token = default) + { + token = CancellationTokenProvider.FallbackToProvider(token); + var value = await GetAsync(key, hideErrors, token); + if (value != null) + { + return value; + } + + using (await SyncSemaphore.LockAsync(token)) + { + value = await GetAsync(key, hideErrors, token); + if (value != null) + { + return value; + } + + value = await factory(); + await SetAsync(key, value, optionsFactory?.Invoke(), hideErrors, token); + } + + return value; + } + + public virtual void Set(TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null) + { + hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; + + try + { + Cache.Set( + NormalizeKey(key.ToString()), + Serializer.Serialize(value), + options ?? DefaultCacheOptions + ); + } + catch (Exception ex) + { + if (hideErrors == true) + { + Logger.LogException(ex, LogLevel.Warning); + return; + } + + throw; + } + } + + public virtual async Task SetAsync(TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, CancellationToken token = default) + { + hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; + + try + { + await Cache.SetAsync( + NormalizeKey(key.ToString()), + Serializer.Serialize(value), + options ?? DefaultCacheOptions, + CancellationTokenProvider.FallbackToProvider(token) + ); + } + catch (Exception ex) + { + if (hideErrors == true) + { + Logger.LogException(ex, LogLevel.Warning); + return; + } + + throw; + } + } + + public virtual void Refresh(TCacheKey key, bool? hideErrors = null) + { + hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; + + try + { + Cache.Refresh(NormalizeKey(key.ToString())); + } + catch (Exception ex) + { + if (hideErrors == true) + { + Logger.LogException(ex, LogLevel.Warning); + return; + } + + throw; + } + } + + public virtual async Task RefreshAsync(TCacheKey key, bool? hideErrors = null, CancellationToken token = default) + { + hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; + + try + { + await Cache.RefreshAsync(NormalizeKey(key.ToString()), CancellationTokenProvider.FallbackToProvider(token)); + } + catch (Exception ex) + { + if (hideErrors == true) + { + Logger.LogException(ex, LogLevel.Warning); + return; + } + + throw; + } + } + + public virtual void Remove(TCacheKey key, bool? hideErrors = null) + { + hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; + + try + { + Cache.Remove(NormalizeKey(key.ToString())); + } + catch (Exception ex) + { + if (hideErrors == true) + { + Logger.LogException(ex, LogLevel.Warning); + } + + throw; + } + } + + public virtual async Task RemoveAsync(TCacheKey key, bool? hideErrors = null, CancellationToken token = default) + { + hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; + + try + { + await Cache.RemoveAsync(NormalizeKey(key.ToString()), CancellationTokenProvider.FallbackToProvider(token)); + } + catch (Exception ex) + { + if (hideErrors == true) + { + Logger.LogException(ex, LogLevel.Warning); + return; + } + + throw; + } + } + + } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs index 23bd6f4cf2..82adeda726 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs @@ -148,4 +148,148 @@ namespace Volo.Abp.Caching CancellationToken token = default ); } + /// + /// Represents a distributed cache of type. + /// Uses a generic cache key type of type. + /// + /// The type of cache item being cached. + /// The type of cache key being used. + public interface IDistributedCache + where TCacheItem : class + { + /// + /// Gets a cache item with the given key. If no cache item is found for the given key then returns null. + /// + /// The key of cached item to be retrieved from the cache. + /// Indicates to throw or hide the exceptions for the distributed cache. + /// The cache item, or null. + TCacheItem Get( + TCacheKey key, + bool? hideErrors = null + ); + + /// + /// Gets a cache item with the given key. If no cache item is found for the given key then returns null. + /// + /// The key of cached item to be retrieved from the cache. + /// Indicates to throw or hide the exceptions for the distributed cache. + /// The for the task. + /// The cache item, or null. + Task GetAsync( + [NotNull] TCacheKey key, + bool? hideErrors = null, + CancellationToken token = default + ); + + /// + /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item + /// provided by delegate and returns the provided cache item. + /// + /// The key of cached item to be retrieved from the cache. + /// The factory delegate is used to provide the cache item when no cache item is found for the given . + /// The cache options for the factory delegate. + /// Indicates to throw or hide the exceptions for the distributed cache. + /// The cache item. + TCacheItem GetOrAdd( + TCacheKey key, + Func factory, + Func optionsFactory = null, + bool? hideErrors = null + ); + + /// + /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item + /// provided by delegate and returns the provided cache item. + /// + /// The key of cached item to be retrieved from the cache. + /// The factory delegate is used to provide the cache item when no cache item is found for the given . + /// The cache options for the factory delegate. + /// Indicates to throw or hide the exceptions for the distributed cache. + /// The for the task. + /// The cache item. + Task GetOrAddAsync( + [NotNull] TCacheKey key, + Func> factory, + Func optionsFactory = null, + bool? hideErrors = null, + CancellationToken token = default + ); + + /// + /// Sets the cache item value for the provided key. + /// + /// The key of cached item to be retrieved from the cache. + /// The cache item value to set in the cache. + /// The cache options for the value. + /// Indicates to throw or hide the exceptions for the distributed cache. + void Set( + TCacheKey key, + TCacheItem value, + DistributedCacheEntryOptions options = null, + bool? hideErrors = null + ); + + /// + /// Sets the cache item value for the provided key. + /// + /// The key of cached item to be retrieved from the cache. + /// The cache item value to set in the cache. + /// The cache options for the value. + /// Indicates to throw or hide the exceptions for the distributed cache. + /// The for the task. + /// The indicating that the operation is asynchronous. + Task SetAsync( + [NotNull] TCacheKey key, + [NotNull] TCacheItem value, + [CanBeNull] DistributedCacheEntryOptions options = null, + bool? hideErrors = null, + CancellationToken token = default + ); + + /// + /// Refreshes the cache value of the given key, and resets its sliding expiration timeout. + /// + /// The key of cached item to be retrieved from the cache. + /// Indicates to throw or hide the exceptions for the distributed cache. + void Refresh( + TCacheKey key, + bool? hideErrors = null + ); + + /// + /// Refreshes the cache value of the given key, and resets its sliding expiration timeout. + /// + /// The key of cached item to be retrieved from the cache. + /// Indicates to throw or hide the exceptions for the distributed cache. + /// The for the task. + /// The indicating that the operation is asynchronous. + Task RefreshAsync( + TCacheKey key, + bool? hideErrors = null, + CancellationToken token = default + ); + + /// + /// Removes the cache item for given key from cache. + /// + /// The key of cached item to be retrieved from the cache. + /// Indicates to throw or hide the exceptions for the distributed cache. + void Remove( + TCacheKey key, + bool? hideErrors = null + ); + + /// + /// Removes the cache item for given key from cache. + /// + /// The key of cached item to be retrieved from the cache. + /// Indicates to throw or hide the exceptions for the distributed cache. + /// The for the task. + /// The indicating that the operation is asynchronous. + Task RemoveAsync( + TCacheKey key, + bool? hideErrors = null, + CancellationToken token = default + ); + } } diff --git a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs index fc6b443893..b802b3e297 100644 --- a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs +++ b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs @@ -122,5 +122,150 @@ namespace Volo.Abp.Caching cacheItem1.ShouldNotBeNull(); } + + [Fact] + public async Task Should_Set_Get_And_Remove_Cache_Items_With_Integer_Type_CacheKey() + { + var personCache = GetRequiredService>(); + + var cacheKey = 42; + const string personName = "john nash"; + + //Get (not exists yet) + var cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldBeNull(); + + //Set + cacheItem = new PersonCacheItem(personName); + await personCache.SetAsync(cacheKey, cacheItem); + + //Get (it should be available now + cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldNotBeNull(); + cacheItem.Name.ShouldBe(personName); + + //Remove + await personCache.RemoveAsync(cacheKey); + + //Get (not exists since removed) + cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldBeNull(); + } + + [Fact] + public async Task GetOrAddAsync_With_Integer_Type_CacheKey() + { + var personCache = GetRequiredService>(); + + var cacheKey = 42; + const string personName = "john nash"; + + //Will execute the factory method to create the cache item + + bool factoryExecuted = false; + + var cacheItem = await personCache.GetOrAddAsync(cacheKey, + async () => + { + factoryExecuted = true; + return new PersonCacheItem(personName); + }); + + factoryExecuted.ShouldBeTrue(); + cacheItem.Name.ShouldBe(personName); + + //This time, it will not execute the factory + + factoryExecuted = false; + + cacheItem = await personCache.GetOrAddAsync(cacheKey, + async () => + { + factoryExecuted = true; + return new PersonCacheItem(personName); + }); + + factoryExecuted.ShouldBeFalse(); + cacheItem.Name.ShouldBe(personName); + } + + [Fact] + public async Task SameClassName_But_DiffNamespace_Should_Not_Use_Same_Cache_With_Integer_CacheKey() + { + var personCache = GetRequiredService>(); + var otherPersonCache = GetRequiredService>(); + + + var cacheKey = 42; + const string personName = "john nash"; + + //Get (not exists yet) + var cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldBeNull(); + + var cacheItem1 = await otherPersonCache.GetAsync(cacheKey); + cacheItem1.ShouldBeNull(); + + //Set + cacheItem = new PersonCacheItem(personName); + await personCache.SetAsync(cacheKey, cacheItem); + + //Get (it should be available now, but otherPersonCache not exists now. + cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldNotBeNull(); + cacheItem.Name.ShouldBe(personName); + + cacheItem1 = await otherPersonCache.GetAsync(cacheKey); + cacheItem1.ShouldBeNull(); + + //set other person cache + cacheItem1 = new Sail.Testing.Caching.PersonCacheItem(personName); + await otherPersonCache.SetAsync(cacheKey, cacheItem1); + + cacheItem1 = await otherPersonCache.GetAsync(cacheKey); + cacheItem1.ShouldNotBeNull(); + cacheItem1.Name.ShouldBe(personName); + + //Remove + await personCache.RemoveAsync(cacheKey); + + + //Get (not exists since removed) + cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldBeNull(); + + cacheItem1 = await otherPersonCache.GetAsync(cacheKey); + cacheItem1.ShouldNotBeNull(); + + } + + [Fact] + public async Task Should_Set_Get_And_Remove_Cache_Items_With_Object_Type_CacheKey() + { + var personCache = GetRequiredService>(); + + var cacheKey = new DummyObjectAsCacheKey { DummyData = "DummyData", DummyInt = 42 }; + const string personName = "john nash"; + + //Get (not exists yet) + var cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldBeNull(); + + //Set + cacheItem = new PersonCacheItem(personName); + await personCache.SetAsync(cacheKey, cacheItem); + + //Get (it should be available now + cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldNotBeNull(); + cacheItem.Name.ShouldBe(personName); + + //Remove + await personCache.RemoveAsync(cacheKey); + + //Get (not exists since removed) + cacheItem = await personCache.GetAsync(cacheKey); + cacheItem.ShouldBeNull(); + } } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/PersonCacheItem.cs b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/PersonCacheItem.cs index b6c6f1dd0a..6b3d9c36df 100644 --- a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/PersonCacheItem.cs +++ b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/PersonCacheItem.cs @@ -17,7 +17,14 @@ namespace Volo.Abp.Caching Name = name; } } + + public class DummyObjectAsCacheKey + { + public string DummyData { get; set; } + public int DummyInt { get; set; } + } } + namespace Sail.Testing.Caching { [Serializable] From 14ea3f2f097c8aae695745eb09da584f4a113170 Mon Sep 17 00:00:00 2001 From: gterdem Date: Tue, 15 Oct 2019 13:14:10 +0300 Subject: [PATCH 02/17] Implemented inheritance for DistributedCache and interface. Fixed issue with complex object ToString resulting same object name as CacheKey. --- .../Volo/Abp/Caching/DistributedCache.cs | 494 ++++-------------- .../Volo/Abp/Caching/IDistributedCache.cs | 135 +---- .../Abp/Caching/DistributedCache_Tests.cs | 42 ++ 3 files changed, 147 insertions(+), 524 deletions(-) diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs index 654e60f323..be8fde19f2 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Caching.Distributed; @@ -15,10 +16,36 @@ namespace Volo.Abp.Caching /// Represents a distributed cache of type. /// /// The type of cache item being cached. - public class DistributedCache : IDistributedCache + public class DistributedCache : DistributedCache, IDistributedCache where TCacheItem : class { - public ILogger> Logger { get; set; } + public DistributedCache( + IOptions cacheOption, + IOptions distributedCacheOption, + IDistributedCache cache, + ICancellationTokenProvider cancellationTokenProvider, + IDistributedCacheSerializer serializer, + ICurrentTenant currentTenant) : base( + cacheOption: cacheOption, + distributedCacheOption: distributedCacheOption, + cache: cache, + cancellationTokenProvider: cancellationTokenProvider, + serializer: serializer, + currentTenant: currentTenant) + { + } + + } + /// + /// Represents a distributed cache of type. + /// Uses a generic cache key type of type. + /// + /// The type of cache item being cached. + /// The type of cache key being used. + public class DistributedCache : IDistributedCache + where TCacheItem : class + { + public ILogger> Logger { get; set; } protected string CacheName { get; set; } @@ -52,7 +79,7 @@ namespace Volo.Abp.Caching _cacheOption = cacheOption.Value; Cache = cache; CancellationTokenProvider = cancellationTokenProvider; - Logger = NullLogger>.Instance; + Logger = NullLogger>.Instance; Serializer = serializer; CurrentTenant = currentTenant; @@ -60,7 +87,60 @@ namespace Volo.Abp.Caching SetDefaultOptions(); } + protected virtual string NormalizeKey(TCacheKey key) + { + Type type = key.GetType(); + string keyValue = key.ToString(); + + // If complex type of object, override the key value with property concatenation + if (!typeof(IComparable).IsAssignableFrom(type) || type.IsPrimitive || type.IsValueType) + { + var sb = new System.Text.StringBuilder(); + var properties = type.GetProperties().Where(prop => prop.CanRead && prop.CanWrite); + + foreach (var prop in properties) + { + var value = prop.GetValue(key, null); + if (value != null) + { + sb.Append(value.ToString()); + } + } + keyValue = sb.ToString(); + } + var normalizedKey = "c:" + CacheName + ",k:" + _cacheOption.KeyPrefix + keyValue; + + if (!IgnoreMultiTenancy && CurrentTenant.Id.HasValue) + { + normalizedKey = "t:" + CurrentTenant.Id.Value + "," + normalizedKey; + } + + return normalizedKey; + } + + protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions() + { + foreach (var configure in _cacheOption.CacheConfigurators) + { + var options = configure.Invoke(CacheName); + if (options != null) + { + return options; + } + } + return _cacheOption.GlobalCacheEntryOptions; + } + + protected virtual void SetDefaultOptions() + { + CacheName = CacheNameAttribute.GetCacheName(typeof(TCacheItem)); + + //IgnoreMultiTenancy + IgnoreMultiTenancy = typeof(TCacheItem).IsDefined(typeof(IgnoreMultiTenancyAttribute), true); + //Configure default cache entry options + DefaultCacheOptions = GetDefaultCacheEntryOptions(); + } /// /// Gets a cache item with the given key. If no cache item is found for the given key then returns null. /// @@ -68,7 +148,7 @@ namespace Volo.Abp.Caching /// Indicates to throw or hide the exceptions for the distributed cache. /// The cache item, or null. public virtual TCacheItem Get( - string key, + TCacheKey key, bool? hideErrors = null) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -106,7 +186,7 @@ namespace Volo.Abp.Caching /// The for the task. /// The cache item, or null. public virtual async Task GetAsync( - string key, + TCacheKey key, bool? hideErrors = null, CancellationToken token = default) { @@ -131,7 +211,7 @@ namespace Volo.Abp.Caching throw; } - + if (cachedBytes == null) { return null; @@ -139,7 +219,6 @@ namespace Volo.Abp.Caching return Serializer.Deserialize(cachedBytes); } - /// /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item /// provided by delegate and returns the provided cache item. @@ -149,10 +228,10 @@ namespace Volo.Abp.Caching /// The cache options for the factory delegate. /// Indicates to throw or hide the exceptions for the distributed cache. /// The cache item. - public TCacheItem GetOrAdd( - string key, - Func factory, - Func optionsFactory = null, + public virtual TCacheItem GetOrAdd( + TCacheKey key, + Func factory, + Func optionsFactory = null, bool? hideErrors = null) { var value = Get(key, hideErrors); @@ -175,7 +254,6 @@ namespace Volo.Abp.Caching return value; } - /// /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item /// provided by delegate and returns the provided cache item. @@ -186,11 +264,11 @@ namespace Volo.Abp.Caching /// Indicates to throw or hide the exceptions for the distributed cache. /// The for the task. /// The cache item. - public async Task GetOrAddAsync( - string key, - Func> factory, - Func optionsFactory = null, - bool? hideErrors = null, + public virtual async Task GetOrAddAsync( + TCacheKey key, + Func> factory, + Func optionsFactory = null, + bool? hideErrors = null, CancellationToken token = default) { token = CancellationTokenProvider.FallbackToProvider(token); @@ -214,7 +292,6 @@ namespace Volo.Abp.Caching return value; } - /// /// Sets the cache item value for the provided key. /// @@ -223,7 +300,7 @@ namespace Volo.Abp.Caching /// The cache options for the value. /// Indicates to throw or hide the exceptions for the distributed cache. public virtual void Set( - string key, + TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null) @@ -249,7 +326,6 @@ namespace Volo.Abp.Caching throw; } } - /// /// Sets the cache item value for the provided key. /// @@ -260,7 +336,7 @@ namespace Volo.Abp.Caching /// The for the task. /// The indicating that the operation is asynchronous. public virtual async Task SetAsync( - string key, + TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, @@ -288,15 +364,14 @@ namespace Volo.Abp.Caching throw; } } - /// /// Refreshes the cache value of the given key, and resets its sliding expiration timeout. /// /// The key of cached item to be retrieved from the cache. /// Indicates to throw or hide the exceptions for the distributed cache. public virtual void Refresh( - string key, - bool? hideErrors = null) + TCacheKey key, bool? + hideErrors = null) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -315,7 +390,6 @@ namespace Volo.Abp.Caching throw; } } - /// /// Refreshes the cache value of the given key, and resets its sliding expiration timeout. /// @@ -324,7 +398,7 @@ namespace Volo.Abp.Caching /// The for the task. /// The indicating that the operation is asynchronous. public virtual async Task RefreshAsync( - string key, + TCacheKey key, bool? hideErrors = null, CancellationToken token = default) { @@ -345,15 +419,13 @@ namespace Volo.Abp.Caching throw; } } - - /// /// Removes the cache item for given key from cache. /// /// The key of cached item to be retrieved from the cache. /// Indicates to throw or hide the exceptions for the distributed cache. public virtual void Remove( - string key, + TCacheKey key, bool? hideErrors = null) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -372,7 +444,6 @@ namespace Volo.Abp.Caching throw; } } - /// /// Removes the cache item for given key from cache. /// @@ -381,7 +452,7 @@ namespace Volo.Abp.Caching /// The for the task. /// The indicating that the operation is asynchronous. public virtual async Task RemoveAsync( - string key, + TCacheKey key, bool? hideErrors = null, CancellationToken token = default) { @@ -402,364 +473,7 @@ namespace Volo.Abp.Caching throw; } } - - protected virtual string NormalizeKey(string key) - { - var normalizedKey = "c:" + CacheName + ",k:" + _cacheOption.KeyPrefix + key; - - if (!IgnoreMultiTenancy && CurrentTenant.Id.HasValue) - { - normalizedKey = "t:" + CurrentTenant.Id.Value + "," + normalizedKey; - } - - return normalizedKey; - } - - protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions() - { - foreach (var configure in _cacheOption.CacheConfigurators) - { - var options = configure.Invoke(CacheName); - if (options != null) - { - return options; - } - } - return _cacheOption.GlobalCacheEntryOptions; - } - - protected virtual void SetDefaultOptions() - { - CacheName = CacheNameAttribute.GetCacheName(typeof(TCacheItem)); - - //IgnoreMultiTenancy - IgnoreMultiTenancy = typeof(TCacheItem).IsDefined(typeof(IgnoreMultiTenancyAttribute), true); - - //Configure default cache entry options - DefaultCacheOptions = GetDefaultCacheEntryOptions(); - } - } - /// - /// Represents a distributed cache of type. - /// Uses a generic cache key type of type. - /// - /// The type of cache item being cached. - /// The type of cache key being used. - public class DistributedCache : IDistributedCache - where TCacheItem : class - { - public ILogger> Logger { get; set; } - - protected string CacheName { get; set; } - - protected bool IgnoreMultiTenancy { get; set; } - - protected IDistributedCache Cache { get; } - - protected ICancellationTokenProvider CancellationTokenProvider { get; } - - protected IDistributedCacheSerializer Serializer { get; } - - protected ICurrentTenant CurrentTenant { get; } - - protected SemaphoreSlim SyncSemaphore { get; } - - protected DistributedCacheEntryOptions DefaultCacheOptions; - - private readonly CacheOptions _cacheOption; - - private readonly DistributedCacheOptions _distributedCacheOption; - - public DistributedCache( - IOptions cacheOption, - IOptions distributedCacheOption, - IDistributedCache cache, - ICancellationTokenProvider cancellationTokenProvider, - IDistributedCacheSerializer serializer, - ICurrentTenant currentTenant) - { - _distributedCacheOption = distributedCacheOption.Value; - _cacheOption = cacheOption.Value; - Cache = cache; - CancellationTokenProvider = cancellationTokenProvider; - Logger = NullLogger>.Instance; - Serializer = serializer; - CurrentTenant = currentTenant; - - SyncSemaphore = new SemaphoreSlim(1, 1); - - SetDefaultOptions(); - } - protected virtual string NormalizeKey(string key) - { - var normalizedKey = "c:" + CacheName + ",k:" + _cacheOption.KeyPrefix + key; - - if (!IgnoreMultiTenancy && CurrentTenant.Id.HasValue) - { - normalizedKey = "t:" + CurrentTenant.Id.Value + "," + normalizedKey; - } - - return normalizedKey; - } - - protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions() - { - foreach (var configure in _cacheOption.CacheConfigurators) - { - var options = configure.Invoke(CacheName); - if (options != null) - { - return options; - } - } - return _cacheOption.GlobalCacheEntryOptions; - } - - protected virtual void SetDefaultOptions() - { - CacheName = CacheNameAttribute.GetCacheName(typeof(TCacheItem)); - - //IgnoreMultiTenancy - IgnoreMultiTenancy = typeof(TCacheItem).IsDefined(typeof(IgnoreMultiTenancyAttribute), true); - - //Configure default cache entry options - DefaultCacheOptions = GetDefaultCacheEntryOptions(); - } - public virtual TCacheItem Get(TCacheKey key, bool? hideErrors = null) - { - hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; - - byte[] cachedBytes; - - try - { - cachedBytes = Cache.Get(NormalizeKey(key?.ToString())); - } - catch (Exception ex) - { - if (hideErrors == true) - { - Logger.LogException(ex, LogLevel.Warning); - return null; - } - - throw; - } - - if (cachedBytes == null) - { - return null; - } - - return Serializer.Deserialize(cachedBytes); - } - - public virtual async Task GetAsync(TCacheKey key, bool? hideErrors = null, CancellationToken token = default) - { - hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; - - byte[] cachedBytes; - - try - { - cachedBytes = await Cache.GetAsync( - NormalizeKey(key.ToString()), - CancellationTokenProvider.FallbackToProvider(token) - ); - } - catch (Exception ex) - { - if (hideErrors == true) - { - Logger.LogException(ex, LogLevel.Warning); - return null; - } - - throw; - } - - if (cachedBytes == null) - { - return null; - } - - return Serializer.Deserialize(cachedBytes); - } - - public virtual TCacheItem GetOrAdd(TCacheKey key, Func factory, Func optionsFactory = null, bool? hideErrors = null) - { - var value = Get(key, hideErrors); - if (value != null) - { - return value; - } - - using (SyncSemaphore.Lock()) - { - value = Get(key, hideErrors); - if (value != null) - { - return value; - } - - value = factory(); - Set(key, value, optionsFactory?.Invoke(), hideErrors); - } - - return value; - } - - public virtual async Task GetOrAddAsync(TCacheKey key, Func> factory, Func optionsFactory = null, bool? hideErrors = null, CancellationToken token = default) - { - token = CancellationTokenProvider.FallbackToProvider(token); - var value = await GetAsync(key, hideErrors, token); - if (value != null) - { - return value; - } - - using (await SyncSemaphore.LockAsync(token)) - { - value = await GetAsync(key, hideErrors, token); - if (value != null) - { - return value; - } - - value = await factory(); - await SetAsync(key, value, optionsFactory?.Invoke(), hideErrors, token); - } - - return value; - } - - public virtual void Set(TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null) - { - hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; - - try - { - Cache.Set( - NormalizeKey(key.ToString()), - Serializer.Serialize(value), - options ?? DefaultCacheOptions - ); - } - catch (Exception ex) - { - if (hideErrors == true) - { - Logger.LogException(ex, LogLevel.Warning); - return; - } - - throw; - } - } - - public virtual async Task SetAsync(TCacheKey key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, CancellationToken token = default) - { - hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; - - try - { - await Cache.SetAsync( - NormalizeKey(key.ToString()), - Serializer.Serialize(value), - options ?? DefaultCacheOptions, - CancellationTokenProvider.FallbackToProvider(token) - ); - } - catch (Exception ex) - { - if (hideErrors == true) - { - Logger.LogException(ex, LogLevel.Warning); - return; - } - - throw; - } - } - - public virtual void Refresh(TCacheKey key, bool? hideErrors = null) - { - hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; - - try - { - Cache.Refresh(NormalizeKey(key.ToString())); - } - catch (Exception ex) - { - if (hideErrors == true) - { - Logger.LogException(ex, LogLevel.Warning); - return; - } - - throw; - } - } - - public virtual async Task RefreshAsync(TCacheKey key, bool? hideErrors = null, CancellationToken token = default) - { - hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; - - try - { - await Cache.RefreshAsync(NormalizeKey(key.ToString()), CancellationTokenProvider.FallbackToProvider(token)); - } - catch (Exception ex) - { - if (hideErrors == true) - { - Logger.LogException(ex, LogLevel.Warning); - return; - } - - throw; - } - } - - public virtual void Remove(TCacheKey key, bool? hideErrors = null) - { - hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; - - try - { - Cache.Remove(NormalizeKey(key.ToString())); - } - catch (Exception ex) - { - if (hideErrors == true) - { - Logger.LogException(ex, LogLevel.Warning); - } - - throw; - } - } - - public virtual async Task RemoveAsync(TCacheKey key, bool? hideErrors = null, CancellationToken token = default) - { - hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; - - try - { - await Cache.RemoveAsync(NormalizeKey(key.ToString()), CancellationTokenProvider.FallbackToProvider(token)); - } - catch (Exception ex) - { - if (hideErrors == true) - { - Logger.LogException(ex, LogLevel.Warning); - return; - } - - throw; - } - } - + } + } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs index 82adeda726..163da05632 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs @@ -10,143 +10,10 @@ namespace Volo.Abp.Caching /// Represents a distributed cache of type. /// /// The type of cache item being cached. - public interface IDistributedCache + public interface IDistributedCache : IDistributedCache where TCacheItem : class { - /// - /// Gets a cache item with the given key. If no cache item is found for the given key then returns null. - /// - /// The key of cached item to be retrieved from the cache. - /// Indicates to throw or hide the exceptions for the distributed cache. - /// The cache item, or null. - TCacheItem Get( - string key, - bool? hideErrors = null - ); - - /// - /// Gets a cache item with the given key. If no cache item is found for the given key then returns null. - /// - /// The key of cached item to be retrieved from the cache. - /// Indicates to throw or hide the exceptions for the distributed cache. - /// The for the task. - /// The cache item, or null. - Task GetAsync( - [NotNull] string key, - bool? hideErrors = null, - CancellationToken token = default - ); - - /// - /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item - /// provided by delegate and returns the provided cache item. - /// - /// The key of cached item to be retrieved from the cache. - /// The factory delegate is used to provide the cache item when no cache item is found for the given . - /// The cache options for the factory delegate. - /// Indicates to throw or hide the exceptions for the distributed cache. - /// The cache item. - TCacheItem GetOrAdd( - string key, - Func factory, - Func optionsFactory = null, - bool? hideErrors = null - ); - /// - /// Gets or Adds a cache item with the given key. If no cache item is found for the given key then adds a cache item - /// provided by delegate and returns the provided cache item. - /// - /// The key of cached item to be retrieved from the cache. - /// The factory delegate is used to provide the cache item when no cache item is found for the given . - /// The cache options for the factory delegate. - /// Indicates to throw or hide the exceptions for the distributed cache. - /// The for the task. - /// The cache item. - Task GetOrAddAsync( - [NotNull] string key, - Func> factory, - Func optionsFactory = null, - bool? hideErrors = null, - CancellationToken token = default - ); - - /// - /// Sets the cache item value for the provided key. - /// - /// The key of cached item to be retrieved from the cache. - /// The cache item value to set in the cache. - /// The cache options for the value. - /// Indicates to throw or hide the exceptions for the distributed cache. - void Set( - string key, - TCacheItem value, - DistributedCacheEntryOptions options = null, - bool? hideErrors = null - ); - - /// - /// Sets the cache item value for the provided key. - /// - /// The key of cached item to be retrieved from the cache. - /// The cache item value to set in the cache. - /// The cache options for the value. - /// Indicates to throw or hide the exceptions for the distributed cache. - /// The for the task. - /// The indicating that the operation is asynchronous. - Task SetAsync( - [NotNull] string key, - [NotNull] TCacheItem value, - [CanBeNull] DistributedCacheEntryOptions options = null, - bool? hideErrors = null, - CancellationToken token = default - ); - - /// - /// Refreshes the cache value of the given key, and resets its sliding expiration timeout. - /// - /// The key of cached item to be retrieved from the cache. - /// Indicates to throw or hide the exceptions for the distributed cache. - void Refresh( - string key, - bool? hideErrors = null - ); - - /// - /// Refreshes the cache value of the given key, and resets its sliding expiration timeout. - /// - /// The key of cached item to be retrieved from the cache. - /// Indicates to throw or hide the exceptions for the distributed cache. - /// The for the task. - /// The indicating that the operation is asynchronous. - Task RefreshAsync( - string key, - bool? hideErrors = null, - CancellationToken token = default - ); - - /// - /// Removes the cache item for given key from cache. - /// - /// The key of cached item to be retrieved from the cache. - /// Indicates to throw or hide the exceptions for the distributed cache. - void Remove( - string key, - bool? hideErrors = null - ); - - /// - /// Removes the cache item for given key from cache. - /// - /// The key of cached item to be retrieved from the cache. - /// Indicates to throw or hide the exceptions for the distributed cache. - /// The for the task. - /// The indicating that the operation is asynchronous. - Task RemoveAsync( - string key, - bool? hideErrors = null, - CancellationToken token = default - ); } /// /// Represents a distributed cache of type. diff --git a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs index b802b3e297..93788e0995 100644 --- a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs +++ b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs @@ -267,5 +267,47 @@ namespace Volo.Abp.Caching cacheItem = await personCache.GetAsync(cacheKey); cacheItem.ShouldBeNull(); } + + [Fact] + public async Task Should_Set_Get_And_Remove_Cache_Items_For_Same_Object_Type_With_Different_CacheKeys() + { + var personCache = GetRequiredService>(); + + var cache1Key = new DummyObjectAsCacheKey { DummyData = "DummyData", DummyInt = 42 }; + var cache2Key = new DummyObjectAsCacheKey { DummyData = "DummyData2", DummyInt = 24 }; + const string personName = "john nash"; + + //Get (not exists yet) + var cacheItem1 = await personCache.GetAsync(cache1Key); + var cacheItem2 = await personCache.GetAsync(cache2Key); + cacheItem1.ShouldBeNull(); + cacheItem2.ShouldBeNull(); + + //Set + cacheItem1 = new PersonCacheItem(personName); + cacheItem2 = new PersonCacheItem(personName); + await personCache.SetAsync(cache1Key, cacheItem1); + await personCache.SetAsync(cache2Key, cacheItem2); + + //Get (it should be available now + cacheItem1 = await personCache.GetAsync(cache1Key); + cacheItem1.ShouldNotBeNull(); + cacheItem1.Name.ShouldBe(personName); + + cacheItem2 = await personCache.GetAsync(cache2Key); + cacheItem2.ShouldNotBeNull(); + cacheItem2.Name.ShouldBe(personName); + + //Remove + await personCache.RemoveAsync(cache1Key); + await personCache.RemoveAsync(cache2Key); + + //Get (not exists since removed) + cacheItem1 = await personCache.GetAsync(cache1Key); + cacheItem1.ShouldBeNull(); + cacheItem2 = await personCache.GetAsync(cache2Key); + cacheItem2.ShouldBeNull(); + } + } } \ No newline at end of file From 00a0dd58e033e2c625fe7367afea0bb39e227ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 18 Oct 2019 15:51:44 +0300 Subject: [PATCH 03/17] Use the provider constant --- .../Abp/SettingManagement/SettingRepository_Tests.cs | 2 +- .../Abp/SettingManagement/SettingTestDataBuilder.cs | 6 +++--- .../SettingCacheItemInvalidator_Tests.cs | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingRepository_Tests.cs b/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingRepository_Tests.cs index ea52e4458c..5dad99a0ca 100644 --- a/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingRepository_Tests.cs +++ b/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingRepository_Tests.cs @@ -30,7 +30,7 @@ namespace Volo.Abp.SettingManagement (await SettingRepository.FindAsync( "MySetting2", - "User", + UserSettingValueProvider.ProviderName, TestData.User1Id.ToString() )).Value.ShouldBe("user1-store-value"); diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs b/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs index a66a4fe253..6843d6257e 100644 --- a/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs +++ b/modules/setting-management/test/Volo.Abp.SettingManagement.TestBase/Volo/Abp/SettingManagement/SettingTestDataBuilder.cs @@ -45,7 +45,7 @@ namespace Volo.Abp.SettingManagement _guidGenerator.Create(), "MySetting2", "user1-store-value", - "User", + UserSettingValueProvider.ProviderName, _testData.User1Id.ToString() ) ); @@ -55,7 +55,7 @@ namespace Volo.Abp.SettingManagement _guidGenerator.Create(), "MySetting2", "user2-store-value", - "User", + UserSettingValueProvider.ProviderName, _testData.User2Id.ToString() ) ); @@ -74,7 +74,7 @@ namespace Volo.Abp.SettingManagement _guidGenerator.Create(), "MySettingWithoutInherit", "user1-store-value", - "User", + UserSettingValueProvider.ProviderName, _testData.User1Id.ToString() ) ); diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingCacheItemInvalidator_Tests.cs b/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingCacheItemInvalidator_Tests.cs index de956d0202..2a458a1739 100644 --- a/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingCacheItemInvalidator_Tests.cs +++ b/modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingCacheItemInvalidator_Tests.cs @@ -29,9 +29,9 @@ namespace Volo.Abp.SettingManagement public async Task GetOrNullAsync_Should_Cached() { // Act - (await _cache.GetAsync(SettingCacheItem.CalculateCacheKey("MySetting2", "User", _testData.User1Id.ToString()))).ShouldBeNull(); - await _settingManagementStore.GetOrNullAsync("MySetting2", "User", _testData.User1Id.ToString()); - (await _cache.GetAsync(SettingCacheItem.CalculateCacheKey("MySetting2", "User", _testData.User1Id.ToString()))).ShouldNotBeNull(); + (await _cache.GetAsync(SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()))).ShouldBeNull(); + await _settingManagementStore.GetOrNullAsync("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()); + (await _cache.GetAsync(SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()))).ShouldNotBeNull(); } [Fact] @@ -39,15 +39,15 @@ namespace Volo.Abp.SettingManagement { // Arrange // GetOrNullAsync will cache language. - await _settingManagementStore.GetOrNullAsync("MySetting2", "User", _testData.User1Id.ToString()); + await _settingManagementStore.GetOrNullAsync("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()); // Act - var lang = await _settingRepository.FindAsync("MySetting2", "User", _testData.User1Id.ToString()); + var lang = await _settingRepository.FindAsync("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()); await _settingRepository.DeleteAsync(lang); // Assert (await _cache.GetAsync( - SettingCacheItem.CalculateCacheKey("MySetting2", "User", _testData.User1Id.ToString()))).ShouldBeNull(); + SettingCacheItem.CalculateCacheKey("MySetting2", UserSettingValueProvider.ProviderName, _testData.User1Id.ToString()))).ShouldBeNull(); } } } From c5a7fb3ee2b97a562d06c33b2fddbd892cceb6ab Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 18 Oct 2019 16:04:31 +0300 Subject: [PATCH 04/17] BackgroundJobs modules abp prefix --- .../app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs | 2 +- ...aredModule.cs => AbpBackgroundJobsDomainSharedModule.cs} | 2 +- ...JobsDomainModule.cs => AbpBackgroundJobsDomainModule.cs} | 6 +++--- .../Volo/Abp/BackgroundJobs/BackgroundJobStore.cs | 4 ++-- ...ule.cs => AbpBackgroundJobsEntityFrameworkCoreModule.cs} | 4 ++-- ...bsMongoDbModule.cs => AbpBackgroundJobsMongoDbModule.cs} | 4 ++-- ...inTestModule.cs => AbpBackgroundJobsDomainTestModule.cs} | 4 ++-- .../Volo/Abp/BackgroundJobs/BackgroundJobsDomainTestBase.cs | 2 +- ...cs => AbpBackgroundJobsEntityFrameworkCoreTestModule.cs} | 6 +++--- .../EntityFrameworkCore/BackgroundJobRepositoryTests.cs | 2 +- ...bTestModule.cs => AbpBackgroundJobsMongoDbTestModule.cs} | 6 +++--- .../BackgroundJobs/MongoDB/BackgroundJobRepositoryTests.cs | 2 +- ...TestBaseModule.cs => AbpBackgroundJobsTestBaseModule.cs} | 4 ++-- .../MyProjectNameDomainSharedModule.cs | 2 +- .../MyProjectNameDomainModule.cs | 2 +- .../MyProjectNameEntityFrameworkCoreModule.cs | 2 +- .../MongoDb/MyProjectNameMongoDbModule.cs | 2 +- 17 files changed, 28 insertions(+), 28 deletions(-) rename modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo/Abp/BackgroundJobs/{BackgroundJobsDomainSharedModule.cs => AbpBackgroundJobsDomainSharedModule.cs} (58%) rename modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/{BackgroundJobsDomainModule.cs => AbpBackgroundJobsDomainModule.cs} (69%) rename modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/{BackgroundJobsEntityFrameworkCoreModule.cs => AbpBackgroundJobsEntityFrameworkCoreModule.cs} (82%) rename modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/{BackgroundJobsMongoDbModule.cs => AbpBackgroundJobsMongoDbModule.cs} (83%) rename modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/{BackgroundJobsDomainTestModule.cs => AbpBackgroundJobsDomainTestModule.cs} (57%) rename modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/{BackgroundJobsEntityFrameworkCoreTestModule.cs => AbpBackgroundJobsEntityFrameworkCoreTestModule.cs} (87%) rename modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/{BackgroundJobsMongoDbTestModule.cs => AbpBackgroundJobsMongoDbTestModule.cs} (82%) rename modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo/Abp/BackgroundJobs/{BackgroundJobsTestBaseModule.cs => AbpBackgroundJobsTestBaseModule.cs} (90%) diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs index 5308053e83..f64191ea3f 100644 --- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs @@ -11,7 +11,7 @@ namespace Volo.Abp.BackgroundJobs.DemoApp { [DependsOn( typeof(DemoAppSharedModule), - typeof(BackgroundJobsEntityFrameworkCoreModule), + typeof(AbpBackgroundJobsEntityFrameworkCoreModule), typeof(AbpAutofacModule), typeof(AbpEntityFrameworkCoreSqlServerModule) )] diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo/Abp/BackgroundJobs/BackgroundJobsDomainSharedModule.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainSharedModule.cs similarity index 58% rename from modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo/Abp/BackgroundJobs/BackgroundJobsDomainSharedModule.cs rename to modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainSharedModule.cs index 2012620f3a..26565fde78 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo/Abp/BackgroundJobs/BackgroundJobsDomainSharedModule.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain.Shared/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainSharedModule.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.BackgroundJobs { - public class BackgroundJobsDomainSharedModule : AbpModule + public class AbpBackgroundJobsDomainSharedModule : AbpModule { } diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDomainModule.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainModule.cs similarity index 69% rename from modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDomainModule.cs rename to modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainModule.cs index 261051958c..a373fd883b 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobsDomainModule.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainModule.cs @@ -5,15 +5,15 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BackgroundJobs { [DependsOn( - typeof(BackgroundJobsDomainSharedModule), + typeof(AbpBackgroundJobsDomainSharedModule), typeof(AbpBackgroundJobsModule), typeof(AbpAutoMapperModule) )] - public class BackgroundJobsDomainModule : AbpModule //TODO: Rename to AbpBackgroundJobsDomainModule + public class AbpBackgroundJobsDomainModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAutoMapperObjectMapper(); + context.Services.AddAutoMapperObjectMapper(); Configure(options => { options.AddProfile(validate: true); diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobStore.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobStore.cs index dce8a31600..2b796d9eaf 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobStore.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.Domain/Volo/Abp/BackgroundJobs/BackgroundJobStore.cs @@ -10,11 +10,11 @@ namespace Volo.Abp.BackgroundJobs { protected IBackgroundJobRepository BackgroundJobRepository { get; } - protected IObjectMapper ObjectMapper { get; } + protected IObjectMapper ObjectMapper { get; } public BackgroundJobStore( IBackgroundJobRepository backgroundJobRepository, - IObjectMapper objectMapper) + IObjectMapper objectMapper) { ObjectMapper = objectMapper; BackgroundJobRepository = backgroundJobRepository; diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsEntityFrameworkCoreModule.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreModule.cs similarity index 82% rename from modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsEntityFrameworkCoreModule.cs rename to modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreModule.cs index 9661dd7646..1c4e6278a5 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsEntityFrameworkCoreModule.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.EntityFrameworkCore/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreModule.cs @@ -5,10 +5,10 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore { [DependsOn( - typeof(BackgroundJobsDomainModule), + typeof(AbpBackgroundJobsDomainModule), typeof(AbpEntityFrameworkCoreModule) )] - public class BackgroundJobsEntityFrameworkCoreModule : AbpModule + public class AbpBackgroundJobsEntityFrameworkCoreModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { diff --git a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbModule.cs b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/AbpBackgroundJobsMongoDbModule.cs similarity index 83% rename from modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbModule.cs rename to modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/AbpBackgroundJobsMongoDbModule.cs index 6ace195fa5..3e98ea6bc2 100644 --- a/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbModule.cs +++ b/modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/AbpBackgroundJobsMongoDbModule.cs @@ -5,10 +5,10 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BackgroundJobs.MongoDB { [DependsOn( - typeof(BackgroundJobsDomainModule), + typeof(AbpBackgroundJobsDomainModule), typeof(AbpMongoDbModule) )] - public class BackgroundJobsMongoDbModule : AbpModule + public class AbpBackgroundJobsMongoDbModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/BackgroundJobsDomainTestModule.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainTestModule.cs similarity index 57% rename from modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/BackgroundJobsDomainTestModule.cs rename to modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainTestModule.cs index d4c861b24c..a9a4bff069 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/BackgroundJobsDomainTestModule.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/AbpBackgroundJobsDomainTestModule.cs @@ -4,9 +4,9 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BackgroundJobs { [DependsOn( - typeof(BackgroundJobsEntityFrameworkCoreTestModule) + typeof(AbpBackgroundJobsEntityFrameworkCoreTestModule) )] - public class BackgroundJobsDomainTestModule : AbpModule + public class AbpBackgroundJobsDomainTestModule : AbpModule { } diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/BackgroundJobsDomainTestBase.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/BackgroundJobsDomainTestBase.cs index 259fbf1929..ae1a2064d3 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/BackgroundJobsDomainTestBase.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.Domain.Tests/Volo/Abp/BackgroundJobs/BackgroundJobsDomainTestBase.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.BackgroundJobs { - public abstract class BackgroundJobsDomainTestBase : BackgroundJobsTestBase + public abstract class BackgroundJobsDomainTestBase : BackgroundJobsTestBase { } diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsEntityFrameworkCoreTestModule.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs similarity index 87% rename from modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsEntityFrameworkCoreTestModule.cs rename to modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs index 70318c1e7a..65ed1194cf 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobsEntityFrameworkCoreTestModule.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs @@ -9,10 +9,10 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore { [DependsOn( - typeof(BackgroundJobsTestBaseModule), - typeof(BackgroundJobsEntityFrameworkCoreModule) + typeof(AbpBackgroundJobsTestBaseModule), + typeof(AbpBackgroundJobsEntityFrameworkCoreModule) )] - public class BackgroundJobsEntityFrameworkCoreTestModule : AbpModule + public class AbpBackgroundJobsEntityFrameworkCoreTestModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobRepositoryTests.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobRepositoryTests.cs index e2f4f22476..42c412037e 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobRepositoryTests.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/BackgroundJobRepositoryTests.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.BackgroundJobs.EntityFrameworkCore { - public class BackgroundJobRepositoryTests : BackgroundJobRepository_Tests + public class BackgroundJobRepositoryTests : BackgroundJobRepository_Tests { } diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbTestModule.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/AbpBackgroundJobsMongoDbTestModule.cs similarity index 82% rename from modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbTestModule.cs rename to modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/AbpBackgroundJobsMongoDbTestModule.cs index e8eba4eb12..4147917829 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobsMongoDbTestModule.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/AbpBackgroundJobsMongoDbTestModule.cs @@ -7,10 +7,10 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BackgroundJobs.MongoDB { [DependsOn( - typeof(BackgroundJobsTestBaseModule), - typeof(BackgroundJobsMongoDbModule) + typeof(AbpBackgroundJobsTestBaseModule), + typeof(AbpBackgroundJobsMongoDbModule) )] - public class BackgroundJobsMongoDbTestModule : AbpModule + public class AbpBackgroundJobsMongoDbTestModule : AbpModule { private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start(); diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobRepositoryTests.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobRepositoryTests.cs index c6106e777a..429cf4821f 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobRepositoryTests.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.MongoDB.Tests/Volo/Abp/BackgroundJobs/MongoDB/BackgroundJobRepositoryTests.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.BackgroundJobs.MongoDB { - public class BackgroundJobRepositoryTests : BackgroundJobRepository_Tests + public class BackgroundJobRepositoryTests : BackgroundJobRepository_Tests { } diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo/Abp/BackgroundJobs/BackgroundJobsTestBaseModule.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo/Abp/BackgroundJobs/AbpBackgroundJobsTestBaseModule.cs similarity index 90% rename from modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo/Abp/BackgroundJobs/BackgroundJobsTestBaseModule.cs rename to modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo/Abp/BackgroundJobs/AbpBackgroundJobsTestBaseModule.cs index 5af07bd6dc..0c1a681eeb 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo/Abp/BackgroundJobs/BackgroundJobsTestBaseModule.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo/Abp/BackgroundJobs/AbpBackgroundJobsTestBaseModule.cs @@ -7,9 +7,9 @@ namespace Volo.Abp.BackgroundJobs [DependsOn( typeof(AbpAutofacModule), typeof(AbpTestBaseModule), - typeof(BackgroundJobsDomainModule) + typeof(AbpBackgroundJobsDomainModule) )] - public class BackgroundJobsTestBaseModule : AbpModule + public class AbpBackgroundJobsTestBaseModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs index cb1f23151e..38e95a5d4b 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs @@ -16,7 +16,7 @@ namespace MyCompanyName.MyProjectName { [DependsOn( typeof(AbpAuditLoggingDomainSharedModule), - typeof(BackgroundJobsDomainSharedModule), + typeof(AbpBackgroundJobsDomainSharedModule), typeof(AbpFeatureManagementDomainSharedModule), typeof(AbpIdentityDomainSharedModule), typeof(AbpIdentityServerDomainSharedModule), diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs index 01d68fa87a..26e2639524 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs @@ -16,7 +16,7 @@ namespace MyCompanyName.MyProjectName [DependsOn( typeof(MyProjectNameDomainSharedModule), typeof(AbpAuditLoggingDomainModule), - typeof(BackgroundJobsDomainModule), + typeof(AbpBackgroundJobsDomainModule), typeof(AbpFeatureManagementDomainModule), typeof(AbpIdentityDomainModule), typeof(AbpPermissionManagementDomainIdentityModule), diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs index 57e0d532fe..9d2f167136 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs @@ -20,7 +20,7 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpEntityFrameworkCoreSqlServerModule), - typeof(BackgroundJobsEntityFrameworkCoreModule), + typeof(AbpBackgroundJobsEntityFrameworkCoreModule), typeof(AbpAuditLoggingEntityFrameworkCoreModule), typeof(AbpTenantManagementEntityFrameworkCoreModule), typeof(AbpFeatureManagementEntityFrameworkCoreModule) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs index 4b450dd3e0..5d3bfabab5 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs @@ -17,7 +17,7 @@ namespace MyCompanyName.MyProjectName.MongoDB typeof(AbpSettingManagementMongoDbModule), typeof(AbpIdentityMongoDbModule), typeof(AbpIdentityServerMongoDbModule), - typeof(BackgroundJobsMongoDbModule), + typeof(AbpBackgroundJobsMongoDbModule), typeof(AbpAuditLoggingMongoDbModule), typeof(AbpTenantManagementMongoDbModule), typeof(AbpFeatureManagementMongoDbModule) From e4957fe45548b7910996aab2dc6b0f9f425e7c04 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 18 Oct 2019 16:08:24 +0300 Subject: [PATCH 05/17] feat: upgrade font awesome --- npm/ng-packs/angular.json | 9 ++++++-- .../apps/dev-app/src/app/app.component.ts | 8 ++++++- .../dev-app/src/app/home/home.component.html | 2 +- npm/ng-packs/package.json | 21 ++++++++++--------- .../packages/theme-shared/ng-package.json | 1 + .../packages/theme-shared/package.json | 3 ++- .../lib/components/button/button.component.ts | 2 +- templates/app/angular/angular.json | 9 ++++++-- .../app/angular/src/app/app.component.ts | 8 ++++++- .../angular/src/app/home/home.component.html | 2 +- 10 files changed, 45 insertions(+), 20 deletions(-) diff --git a/npm/ng-packs/angular.json b/npm/ng-packs/angular.json index f1c7d18a46..cfa01cf43f 100644 --- a/npm/ng-packs/angular.json +++ b/npm/ng-packs/angular.json @@ -435,9 +435,14 @@ "apps/dev-app/src/styles.scss", "node_modules/bootstrap/dist/css/bootstrap.min.css", { - "input": "node_modules/font-awesome/css/font-awesome.min.css", + "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", "lazy": true, - "bundleName": "font-awesome.min" + "bundleName": "fontawesome-all.min" + }, + { + "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", + "lazy": true, + "bundleName": "fontawesome-v4-shims.min" }, { "input": "node_modules/primeng/resources/themes/nova-light/theme.css", diff --git a/npm/ng-packs/apps/dev-app/src/app/app.component.ts b/npm/ng-packs/apps/dev-app/src/app/app.component.ts index e89c73184d..4780afbfd5 100644 --- a/npm/ng-packs/apps/dev-app/src/app/app.component.ts +++ b/npm/ng-packs/apps/dev-app/src/app/app.component.ts @@ -14,7 +14,13 @@ export class AppComponent implements OnInit { ngOnInit() { this.lazyLoadService .load( - ['primeng.min.css', 'primeicons.css', 'primeng-nova-light-theme.css', 'font-awesome.min.css'], + [ + 'primeng.min.css', + 'primeicons.css', + 'primeng-nova-light-theme.css', + 'fontawesome-all.min.css', + 'fontawesome-v4-shims.min.css', + ], 'style', null, 'head', diff --git a/npm/ng-packs/apps/dev-app/src/app/home/home.component.html b/npm/ng-packs/apps/dev-app/src/app/home/home.component.html index 4fafc67398..79220d16c4 100644 --- a/npm/ng-packs/apps/dev-app/src/app/home/home.component.html +++ b/npm/ng-packs/apps/dev-app/src/app/home/home.component.html @@ -6,7 +6,7 @@

{{ 'AbpIdentity::Login' | abpLocalization }}{{ 'AbpIdentity::Login' | abpLocalization }}


diff --git a/npm/ng-packs/package.json b/npm/ng-packs/package.json index 3774a5705d..abee172af0 100644 --- a/npm/ng-packs/package.json +++ b/npm/ng-packs/package.json @@ -7,13 +7,17 @@ "abpng": "abpng", "commit": "git-cz && node scripts/push.js", "lint": "ng lint --fix", - "build:scripts": "cd scripts && npm install && npm run build" + "scripts:build": "cd scripts && npm install && npm run build" }, "devDependencies": { - "@abp/ng.core": "^0.9.0", - "@abp/ng.feature-management": "^0.9.0", - "@abp/ng.permission-management": "^0.9.0", - "@abp/ng.theme.shared": "^0.9.0", + "@abp/ng.account.config": "0.9.2", + "@abp/ng.core": "0.9.2", + "@abp/ng.feature-management": "0.9.2", + "@abp/ng.identity.config": "0.9.2", + "@abp/ng.permission-management": "0.9.2", + "@abp/ng.setting-management.config": "0.9.2", + "@abp/ng.tenant-management.config": "0.9.2", + "@abp/ng.theme.shared": "0.9.2", "@angular-builders/jest": "^8.2.0", "@angular-devkit/build-angular": "~0.803.6", "@angular-devkit/build-ng-packagr": "~0.803.6", @@ -29,6 +33,7 @@ "@angular/platform-browser": "~8.2.8", "@angular/platform-browser-dynamic": "~8.2.8", "@angular/router": "~8.1.2", + "@fortawesome/fontawesome-free": "^5.11.2", "@ng-bootstrap/ng-bootstrap": "^5.1.0", "@ngneat/spectator": "^4.4.0", "@ngx-validate/core": "^0.0.7", @@ -64,11 +69,7 @@ "tsickle": "^0.37.0", "tslint": "~5.20.0", "typescript": "~3.5.3", - "zone.js": "~0.9.1", - "@abp/ng.account.config": "^0.9.0", - "@abp/ng.identity.config": "0.9.0", - "@abp/ng.tenant-management.config": "^0.9.0", - "@abp/ng.setting-management.config": "^0.9.0" + "zone.js": "~0.9.1" }, "dependencies": { "tslib": "^1.10.0" diff --git a/npm/ng-packs/packages/theme-shared/ng-package.json b/npm/ng-packs/packages/theme-shared/ng-package.json index 984eb7c61a..a879347afd 100644 --- a/npm/ng-packs/packages/theme-shared/ng-package.json +++ b/npm/ng-packs/packages/theme-shared/ng-package.json @@ -7,6 +7,7 @@ "whitelistedNonPeerDependencies": [ "@abp/ng.core", "@angular/cdk", + "@fortawesome/fontawesome-free", "@ng-bootstrap/ng-bootstrap", "@ngx-validate/core", "bootstrap", diff --git a/npm/ng-packs/packages/theme-shared/package.json b/npm/ng-packs/packages/theme-shared/package.json index 813efd2932..0480977d6f 100644 --- a/npm/ng-packs/packages/theme-shared/package.json +++ b/npm/ng-packs/packages/theme-shared/package.json @@ -4,6 +4,7 @@ "dependencies": { "@abp/ng.core": "^0.9.2", "@angular/cdk": "^8.0.1", + "@fortawesome/fontawesome-free": "5.10.1", "@ng-bootstrap/ng-bootstrap": "^5.1.0", "@ngx-validate/core": "^0.0.7", "bootstrap": "^4.3.1", @@ -11,7 +12,7 @@ "font-awesome": "^4.7.0", "ngx-perfect-scrollbar": "^8.0.0", "primeicons": "^2.0.0", - "primeng": "^8.0.3" + "primeng": "^8.0.4" }, "publishConfig": { "access": "public" diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts b/npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts index 99d58d3124..569484867b 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts @@ -55,7 +55,7 @@ export class ButtonComponent implements OnInit { @Input() type = 'button'; get icon(): string { - return `${this.loading ? 'fa fa-pulse fa-spinner' : this.iconClass || 'd-none'}`; + return `${this.loading ? 'fa fa-spinner fa-spin' : this.iconClass || 'd-none'}`; } constructor(private renderer: Renderer2) {} diff --git a/templates/app/angular/angular.json b/templates/app/angular/angular.json index f7bb4656fe..4b1f31497b 100644 --- a/templates/app/angular/angular.json +++ b/templates/app/angular/angular.json @@ -29,9 +29,14 @@ "src/styles.scss", "node_modules/bootstrap/dist/css/bootstrap.min.css", { - "input": "node_modules/font-awesome/css/font-awesome.min.css", + "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", "lazy": true, - "bundleName": "font-awesome.min" + "bundleName": "fontawesome-all.min" + }, + { + "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", + "lazy": true, + "bundleName": "fontawesome-v4-shims.min" }, { "input": "node_modules/primeng/resources/themes/nova-light/theme.css", diff --git a/templates/app/angular/src/app/app.component.ts b/templates/app/angular/src/app/app.component.ts index e89c73184d..4780afbfd5 100644 --- a/templates/app/angular/src/app/app.component.ts +++ b/templates/app/angular/src/app/app.component.ts @@ -14,7 +14,13 @@ export class AppComponent implements OnInit { ngOnInit() { this.lazyLoadService .load( - ['primeng.min.css', 'primeicons.css', 'primeng-nova-light-theme.css', 'font-awesome.min.css'], + [ + 'primeng.min.css', + 'primeicons.css', + 'primeng-nova-light-theme.css', + 'fontawesome-all.min.css', + 'fontawesome-v4-shims.min.css', + ], 'style', null, 'head', diff --git a/templates/app/angular/src/app/home/home.component.html b/templates/app/angular/src/app/home/home.component.html index 4fafc67398..79220d16c4 100644 --- a/templates/app/angular/src/app/home/home.component.html +++ b/templates/app/angular/src/app/home/home.component.html @@ -6,7 +6,7 @@

{{ 'AbpIdentity::Login' | abpLocalization }}{{ 'AbpIdentity::Login' | abpLocalization }}


From 6a575eab23256f20c4603feac013e487d2bbcf5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 18 Oct 2019 16:24:59 +0300 Subject: [PATCH 06/17] Use AbpMultiTenancyOptions --- .../Themes/Basic/Layouts/Account.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml index 7e855834da..7b43c6d969 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml @@ -14,7 +14,7 @@ @using Volo.Abp.MultiTenancy @inject IAbpAntiForgeryManager AbpAntiForgeryManager @inject IBrandingProvider BrandingProvider -@inject IOptions MultiTenancyOptions +@inject IOptions MultiTenancyOptions @inject ICurrentTenant CurrentTenant @inject IStringLocalizer MultiTenancyStringLocalizer @inject ITenantResolveResultAccessor TenantResolveResultAccessor From e1828614702d646feab3e4d73696d894d63bbc55 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 18 Oct 2019 17:14:39 +0300 Subject: [PATCH 07/17] fix: table columns --- .../identity/src/lib/components/roles/roles.component.html | 6 +++--- .../identity/src/lib/components/users/users.component.html | 6 +++--- .../src/lib/components/tenants/tenants.component.html | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html index 822c5a9576..4de916e77b 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html +++ b/npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.html @@ -23,7 +23,7 @@ /> - + @@ -65,7 +65,7 @@ - +
- + @@ -76,7 +76,7 @@ - +
- + @@ -68,7 +68,7 @@ - +