27 lines
677 B
C#
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;
|
|
}
|
|
}
|
|
} |