feat(wpf): Wpf旧Config增加int读取 (#11987)

This commit is contained in:
status102
2025-02-24 23:38:51 +08:00
committed by GitHub
parent 7a34a175e6
commit faff79e9c6

View File

@@ -72,6 +72,18 @@ namespace MaaWpfGui.Helper
return defaultValue;
}
/// <summary>
/// Get a configuration value
/// </summary>
/// <param name="key">The config key</param>
/// <param name="defaultValue">The default value to return if the key is not existed</param>
/// <returns>The config value</returns>
public static int GetValue(string key, int defaultValue)
{
var value = GetValue(key, defaultValue.ToString());
return int.TryParse(value, out var result) ? result : defaultValue;
}
public static string GetGlobalValue(string key, string defaultValue)
{
var hasValue = _globalKvs.TryGetValue(key, out var value);
@@ -148,6 +160,8 @@ namespace MaaWpfGui.Helper
return result;
}
public static bool ContainsKey(string key, bool isGlobal = false) => isGlobal ? _globalKvs.ContainsKey(key) : _kvs.ContainsKey(key);
/// <summary>
/// Deletes a configuration
/// </summary>