IndieGame/client/Assets/Ether/Scripts/Module/Data/DataBase.cs

29 lines
624 B
C#
Raw Normal View History

namespace Ether
{
public abstract class DataBase
{
private DictionaryEx<string, object> allDataDic = new DictionaryEx<string, object>();
public bool AddData(string name, object value)
{
if (allDataDic.ContainsKey(name))
{
return false;
}
allDataDic.Add(name, value);
return true;
}
public T GetData<T>(string name)
{
if (allDataDic.TryGetValue(name, out object value))
{
return (T)value;
}
return default;
}
}
}