mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move ClearEmpty to DatFile
This commit is contained in:
@@ -190,45 +190,10 @@ namespace SabreTools.DatFiles
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove any keys that have null or empty values
|
||||
/// </summary>
|
||||
internal void ClearEmpty()
|
||||
{
|
||||
foreach (string key in SortedKeys)
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
// If the key doesn't exist, skip
|
||||
if (!_items.TryGetValue(key, out var value))
|
||||
continue;
|
||||
|
||||
// If the value is null, remove
|
||||
else if (value == null)
|
||||
_items.TryRemove(key, out _);
|
||||
|
||||
// If there are no non-blank items, remove
|
||||
else if (value!.FindIndex(i => i != null && i is not Blank) == -1)
|
||||
_items.TryRemove(key, out _);
|
||||
#else
|
||||
// If the key doesn't exist, skip
|
||||
if (!_items.ContainsKey(key))
|
||||
continue;
|
||||
|
||||
// If the value is null, remove
|
||||
else if (_items[key] == null)
|
||||
_items.Remove(key);
|
||||
|
||||
// If there are no non-blank items, remove
|
||||
else if (_items[key]!.FindIndex(i => i != null && i is not Blank) == -1)
|
||||
_items.Remove(key);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all items marked for removal
|
||||
/// </summary>
|
||||
internal void ClearMarked()
|
||||
public void ClearMarked()
|
||||
{
|
||||
foreach (string key in SortedKeys)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user