mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-24 19:33:10 +00:00
e3efa65160
handle messages for dirty cleaning :)
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Processes input of strings into a list of valid Filters and Instructions.
|
|
/// </summary>
|
|
public sealed class StringInstructionSet
|
|
{
|
|
public readonly IReadOnlyList<StringInstruction> Filters;
|
|
public readonly IReadOnlyList<StringInstruction> Instructions;
|
|
|
|
private const string SetSeparator = ";";
|
|
|
|
public StringInstructionSet(IReadOnlyList<StringInstruction> filters, IReadOnlyList<StringInstruction> instructions)
|
|
{
|
|
Filters = filters;
|
|
Instructions = instructions;
|
|
}
|
|
|
|
public StringInstructionSet(ICollection<string> set)
|
|
{
|
|
Filters = StringInstruction.GetFilters(set).ToList();
|
|
Instructions = StringInstruction.GetInstructions(set).ToList();
|
|
}
|
|
|
|
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 new StringInstructionSet(list);
|
|
}
|
|
}
|
|
}
|
|
}
|