mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-11 19:27:26 +08:00
[O] ResetTouchAfterTrack -> ResetTouch, add press key to reset (#93)
* [O] ResetTouchAfterTrack -> ResetTouch, add press key to reset * fix * update * fix: Remove not work --------- Co-authored-by: Menci <mencici@msn.com>
This commit is contained in:
@@ -59,6 +59,12 @@ public class ConfigView : IConfigView
|
||||
}
|
||||
current = (TomlTable)next;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
current.Keys.Remove(pathComponents.Last());
|
||||
return;
|
||||
}
|
||||
current.Put(pathComponents.Last(), value);
|
||||
}
|
||||
|
||||
@@ -85,6 +91,11 @@ public class ConfigView : IConfigView
|
||||
resultValue = default;
|
||||
return false;
|
||||
}
|
||||
if (typeof(T) == typeof(object))
|
||||
{
|
||||
resultValue = (T)(object)value;
|
||||
return true;
|
||||
}
|
||||
try
|
||||
{
|
||||
resultValue = Utility.ParseTomlValue<T>(value);
|
||||
@@ -98,8 +109,34 @@ public class ConfigView : IConfigView
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(string path)
|
||||
{
|
||||
var pathComponents = path.Split('.');
|
||||
var current = root;
|
||||
foreach (var component in pathComponents.Take(pathComponents.Length - 1))
|
||||
{
|
||||
if (!Utility.TomlTryGetValueCaseInsensitive(current, component, out var next) || next is not TomlTable nextTable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
current = (TomlTable)next;
|
||||
}
|
||||
var keyToRemove = pathComponents.Last();
|
||||
var keysCaseSensitive = current.Keys.Where(k => string.Equals(k, keyToRemove, StringComparison.OrdinalIgnoreCase));
|
||||
foreach (var key in keysCaseSensitive)
|
||||
{
|
||||
current.Entries.Remove(key);
|
||||
}
|
||||
return keysCaseSensitive.Any();
|
||||
}
|
||||
|
||||
public string ToToml()
|
||||
{
|
||||
return root.SerializedValue;
|
||||
}
|
||||
|
||||
public IConfigView Clone()
|
||||
{
|
||||
return new ConfigView(ToToml());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user