BITFALL/Assets/BITKit/Core/Extensions/Generic.cs

24 lines
701 B
C#
Raw Normal View History

2023-08-12 01:43:24 +08:00
using System.Collections.Concurrent;
namespace BITKit
{
public static class Generic<T>
{
2023-08-23 01:59:40 +08:00
private static readonly string typeName = $"{typeof(T).FullName}.";
private static readonly ConcurrentDictionary<string, string> cacheMap = new();
2023-08-12 01:43:24 +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;
}
}
}