using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace KssSmaPlaLib.InBox { public class LineFilterUxer : IFilterUxer { private readonly HashSet includedLines; private readonly HashSet excludedLines; public LineFilterUxer(IEnumerable included, IEnumerable excluded) { includedLines = new HashSet(included ?? Enumerable.Empty()); excludedLines = new HashSet(excluded ?? Enumerable.Empty()); } public IEnumerable ApplyFilter(IEnumerable lineNames) { if (includedLines.Any()) { // Included優先 → lineNamesの中でincludedに含まれるものだけ返す return lineNames.Where(name => includedLines.Contains(name)); } // Excluded適用 → lineNamesの中でexcludedに含まれないものだけ返す return lineNames.Where(name => !excludedLines.Contains(name)); } public bool CanPass(string lineName) { return HasAnyPass(new[] { lineName }); } public bool HasAnyPass(IEnumerable candidates) { return ApplyFilter(candidates).Any(); } } }