You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/CacheNameAttribute.cs

34 lines
893 B

using System;
using System.Linq;
using JetBrains.Annotations;
namespace Volo.Abp.Caching
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct)]
public class CacheNameAttribute : Attribute
{
public string Name { get; }
public CacheNameAttribute([NotNull] string name)
{
Check.NotNull(name, nameof(name));
Name = name;
}
public static string GetCacheName(Type cacheItemType)
{
var cacheNameAttribute = cacheItemType
.GetCustomAttributes(true)
.OfType<CacheNameAttribute>()
.FirstOrDefault();
if (cacheNameAttribute != null)
{
return cacheNameAttribute.Name;
}
return cacheItemType.FullName.RemovePostFix("CacheItem");
}
}
}