vengine初步实现增删改查
This commit is contained in:
45
common/Tnb.Common/Models/DObject.cs
Normal file
45
common/Tnb.Common/Models/DObject.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
namespace Tnb.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 字典对象
|
||||
/// </summary>
|
||||
public class DObject : Dictionary<string, object>
|
||||
{
|
||||
public DObject() { }
|
||||
public DObject(string key, object value)
|
||||
{
|
||||
Add(key, value);
|
||||
}
|
||||
public DObject(Dictionary<string, object> dictionary) : base(dictionary)
|
||||
{
|
||||
}
|
||||
public void AddCascade(string code, object value)
|
||||
{
|
||||
var keys = code.Split('.');
|
||||
if (keys.Length == 1)
|
||||
{
|
||||
Add(code, value);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < keys.Length; i++)
|
||||
{
|
||||
DObject temp = this;
|
||||
if (i < keys.Length - 1)
|
||||
{
|
||||
if (!ContainsKey(keys[i]))
|
||||
{
|
||||
temp = new DObject();
|
||||
Add(keys[i], temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = (DObject)temp[keys[i]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
temp.Add(keys[i], value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user