添加get;

This commit is contained in:
milimoe 2024-03-18 21:16:14 +08:00
parent 8938581805
commit 8570b72e2b
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
2 changed files with 29 additions and 4 deletions

View File

@ -31,9 +31,13 @@ namespace Milimoe.FunGame.Core.Api.Utility
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public new object this[string key]
public new object? this[string key]
{
set => Add(key, value);
get => GetValue(key);
set
{
if (value != null) Add(key, value);
}
}
/// <summary>
@ -53,6 +57,20 @@ namespace Milimoe.FunGame.Core.Api.Utility
}
}
/// <summary>
/// 获取指定key的value
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public object? GetValue(string key)
{
if (base.TryGetValue(key, out object? value) && value != null)
{
return value;
}
return null;
}
/// <summary>
/// 使用泛型获取指定key的value
/// </summary>

View File

@ -828,6 +828,13 @@
<typeparam name="T"></typeparam>
<param name="key"></param>
</member>
<member name="M:Milimoe.FunGame.Core.Api.Utility.PluginConfig.GetValue(System.String)">
<summary>
获取指定key的value
</summary>
<param name="key"></param>
<returns></returns>
</member>
<member name="M:Milimoe.FunGame.Core.Api.Utility.PluginConfig.Get``1(System.String)">
<summary>
使用泛型获取指定key的value