PKHeX/PKHeX.Core/Editing/Bulk/StringInstructionSet.cs
Kurt d772a82953 Move batch editor logic to core
previous hurdle a year ago was propertyinfo fetching not looking at the
base class's properties; dig deeper for all properties to mimic existing
code for netframework

end result is batch editing now possible without gui
2018-05-17 22:43:07 -07:00

34 lines
1 KiB
C#

using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core
{
// Utility Methods
public class StringInstructionSet
{
public IList<StringInstruction> Filters { get; private set; }
public IList<StringInstruction> Instructions { get; private set; }
private const string SetSeparator = ";";
public static IEnumerable<StringInstructionSet> GetBatchSets(string[] lines)
{
int start = 0;
while (start < lines.Length)
{
var list = lines.Skip(start).TakeWhile(_ => !lines[start++].StartsWith(SetSeparator)).ToList();
yield return GetBatchSet(list);
}
}
private static StringInstructionSet GetBatchSet(IList<string> set)
{
return new StringInstructionSet
{
Filters = StringInstruction.GetFilters(set).ToList(),
Instructions = StringInstruction.GetInstructions(set).ToList(),
};
}
}
}