mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
Move required extension
This commit is contained in:
@@ -859,25 +859,5 @@ namespace SabreTools.Data.Extensions
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Reading
|
||||
|
||||
/// <summary>
|
||||
/// Read an item array from a given key, if possible
|
||||
/// </summary>
|
||||
public static T[]? ReadItemArray<T>(this DictionaryBase self, string key) where T : DictionaryBase
|
||||
{
|
||||
var items = self.Read<T[]>(key);
|
||||
if (items == default)
|
||||
{
|
||||
var single = self.Read<T>(key);
|
||||
if (single != default)
|
||||
items = [single];
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,25 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return this[key]!.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a key as a T[], returning null on error
|
||||
/// </summary>
|
||||
public T[]? ReadArray<T>(string key)
|
||||
{
|
||||
if (!ValidateReadKey(key))
|
||||
return null;
|
||||
|
||||
var items = Read<T[]>(key);
|
||||
if (items is not null)
|
||||
return items;
|
||||
|
||||
var single = Read<T>(key);
|
||||
if (single is not null)
|
||||
return [single];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a key as a string[], returning null on error
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user