PKHeX/PKHeX.Core/Editing/Bulk/StringInstructionSet.cs
Kurt 3c7d083c1e Add more utility to batcheditor
method ( string[] , pkm[] )
carry out batch edit, all within core (no gui needed)
2018-05-21 17:04:02 -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(IList<string> lines)
{
int start = 0;
while (start < lines.Count)
{
var list = lines.Skip(start).TakeWhile(_ => !lines[start++].StartsWith(SetSeparator)).ToList();
yield return GetBatchSet(list);
}
}
private static StringInstructionSet GetBatchSet(ICollection<string> set)
{
return new StringInstructionSet
{
Filters = StringInstruction.GetFilters(set).ToList(),
Instructions = StringInstruction.GetInstructions(set).ToList(),
};
}
}
}