Files
Fishing2/Assets/Scripts/Configs/Cache/Configs.cs
2025-05-10 12:49:47 +08:00

27 lines
677 B
C#

using System;
using System.Collections.Generic;
namespace NBF
{
public static class Configs
{
private static readonly Dictionary<Type, IConfigContext> _dictionary = new Dictionary<Type, IConfigContext>();
static Configs()
{
}
public static ConfigContext<T> Table<T>() where T : ConfigBase
{
var type = typeof(T);
if (_dictionary.TryGetValue(type, out var context))
{
return context as ConfigContext<T>;
}
var jsonContext = new ConfigContext<T>();
_dictionary[type] = jsonContext;
return jsonContext;
}
}
}