25 lines
760 B
C#
25 lines
760 B
C#
using System.Collections.Concurrent;
|
|
namespace BITKit
|
|
{
|
|
public static class Generic<T>
|
|
{
|
|
private static readonly string typeName = $"{typeof(T).FullName}.";
|
|
private static readonly ConcurrentDictionary<string, string> cacheMap = new();
|
|
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;
|
|
}
|
|
public static int Hash => typeof(T).GetHashCode();
|
|
}
|
|
}
|