2020-04-26 23:23:06 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2021-06-07 06:34:15 +00:00
|
|
|
|
namespace PKHeX.Core
|
2020-04-26 23:23:06 +00:00
|
|
|
|
{
|
2021-01-07 07:30:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Utilizes Reflection to obtain all defined accessor property names and object values.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">Type of accessor</typeparam>
|
2020-09-07 20:51:13 +00:00
|
|
|
|
public sealed class SaveBlockMetadata<T>
|
2020-04-26 23:23:06 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly Dictionary<SaveBlock, string> BlockList;
|
|
|
|
|
|
|
|
|
|
public SaveBlockMetadata(ISaveBlockAccessor<T> accessor)
|
|
|
|
|
{
|
|
|
|
|
var aType = accessor.GetType();
|
|
|
|
|
BlockList = aType.GetAllPropertiesOfType<SaveBlock>(accessor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<string> GetSortedBlockList()
|
|
|
|
|
{
|
|
|
|
|
return BlockList.Select(z => z.Value).OrderBy(z => z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SaveBlock GetBlock(string name) => BlockList.First(z => z.Value == name).Key;
|
|
|
|
|
}
|
|
|
|
|
}
|