mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Create and use Cleaner
This commit is contained in:
@@ -715,6 +715,28 @@ namespace SabreTools.Library.DatFiles
|
||||
ClearEmpty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove any keys that have null or empty values
|
||||
/// </summary>
|
||||
public void ClearEmpty()
|
||||
{
|
||||
var keys = items.Keys.Where(k => k != null).ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
// 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].Count(i => i != null && i.ItemType != ItemType.Blank) == 0)
|
||||
items.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all items marked for removal
|
||||
/// </summary>
|
||||
@@ -829,22 +851,6 @@ namespace SabreTools.Library.DatFiles
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove any keys that have null or empty values
|
||||
/// </summary>
|
||||
private void ClearEmpty()
|
||||
{
|
||||
var keys = items.Keys.Where(k => k != null).ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
if (!items.ContainsKey(key))
|
||||
continue;
|
||||
|
||||
if (items[key] == null || items[key].Count == 0)
|
||||
items.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the highest-order Field value that represents the statistics
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user