表格重构
This commit is contained in:
27
Assets/Scripts/Configs~/Cache/Configs.cs
Normal file
27
Assets/Scripts/Configs~/Cache/Configs.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user