59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
|
|
namespace Guru
|
||
|
|
{
|
||
|
|
public struct PropertyKey
|
||
|
|
{
|
||
|
|
public const int UsageGeneral = 0;
|
||
|
|
public const int UsageSettings = 1;
|
||
|
|
public const string DefaultGroup = "guru";
|
||
|
|
|
||
|
|
public string name { get; private set; }
|
||
|
|
public string key { get; private set; }
|
||
|
|
public string group { get; private set; }
|
||
|
|
public string tag { get; private set; }
|
||
|
|
public int usage { get; private set; }
|
||
|
|
|
||
|
|
public static PropertyKey General(string name, string group = DefaultGroup, string tag = "")
|
||
|
|
{
|
||
|
|
return new PropertyKey
|
||
|
|
{
|
||
|
|
name = name,
|
||
|
|
key = $"{group}@{name}",
|
||
|
|
group = group,
|
||
|
|
tag = tag,
|
||
|
|
usage = UsageGeneral
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
public static PropertyKey Setting(string name, string group = DefaultGroup, string tag = "")
|
||
|
|
{
|
||
|
|
return new PropertyKey
|
||
|
|
{
|
||
|
|
name = name,
|
||
|
|
key = $"{group}@{name}",
|
||
|
|
group = group,
|
||
|
|
tag = tag,
|
||
|
|
usage = UsageSettings
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 判断两个属性 Key 是否相等
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="other"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public bool Equals(PropertyKey other)
|
||
|
|
{
|
||
|
|
return name == other.name &&
|
||
|
|
key == other.key &&
|
||
|
|
group == other.group &&
|
||
|
|
tag == other.tag &&
|
||
|
|
usage == other.usage;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override string ToString()
|
||
|
|
{
|
||
|
|
return $"#{tag}#[{key}]({usage})";
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|