BITKit/Src/Core/Extensions/Generic.cs

25 lines
760 B
C#
Raw Normal View History

2023-06-29 14:57:11 +08:00
using System.Collections.Concurrent;
2023-06-05 19:57:17 +08:00
namespace BITKit
{
public static class Generic<T>
{
2023-08-23 01:59:26 +08:00
private static readonly string typeName = $"{typeof(T).FullName}.";
private static readonly ConcurrentDictionary<string, string> cacheMap = new();
2023-06-05 19:57:17 +08:00
public static string GetVariable(string str)
{
if (cacheMap.TryGetValue(str, out var cacheName))
{
}
else
{
cacheName = string.Concat(typeName, str);
cacheMap.AddOrUpdate(str, x => cacheName, (x, y) => cacheName);
return string.Concat(typeName, str);
}
return cacheName;
}
2024-03-31 23:31:00 +08:00
public static int Hash => typeof(T).GetHashCode();
2023-06-05 19:57:17 +08:00
}
}