diff --git a/TextParser/Data/DataSetManipulatorBase.cs b/TextParser/Data/DataSetManipulatorBase.cs index 582d815..2311537 100644 --- a/TextParser/Data/DataSetManipulatorBase.cs +++ b/TextParser/Data/DataSetManipulatorBase.cs @@ -4,11 +4,22 @@ namespace Parsing.Data; public class SearchResult { + public SearchResult(IDataIndex dataIndex) + { + this.DataIndex = dataIndex; + } + public IDataIndex? DataIndex { get; set; } } public class DirectionalSearchResult : SearchResult { + public DirectionalSearchResult(IDataIndex dataIndex, Direction direction, int length): base(dataIndex) + { + this.Direction = direction; + this.Length = length; + } + public Direction Direction { get; set; } public int Length { get; set; } } @@ -111,10 +122,7 @@ public abstract class DataSetManipulatorBase(); - result.DataIndex = currentPosition; - result.Direction = direction; - result.Length = searchIndex; + var result = new DirectionalSearchResult(currentPosition, direction, searchIndex); results.Add(result); } } diff --git a/TextParser/Data/DefaultOneDimensionalManipulator.cs b/TextParser/Data/DefaultOneDimensionalManipulator.cs index 5124ab8..4ecf047 100644 --- a/TextParser/Data/DefaultOneDimensionalManipulator.cs +++ b/TextParser/Data/DefaultOneDimensionalManipulator.cs @@ -49,8 +49,7 @@ public class DefaultOneDimensionalManipulator : DataSetManipulatorBas { if (EqualityComparer.Default.Equals(this.dataSet[i], data)) { - var singleResult = new SearchResult(); - singleResult.DataIndex = new DefaultPositionalDataIndex(i); + var singleResult = new SearchResult(new DefaultPositionalDataIndex(i)); results.Add(singleResult); } } diff --git a/TextParser/Data/DefaultTwoDimensionalManipulator.cs b/TextParser/Data/DefaultTwoDimensionalManipulator.cs index e712a99..5feb3ea 100644 --- a/TextParser/Data/DefaultTwoDimensionalManipulator.cs +++ b/TextParser/Data/DefaultTwoDimensionalManipulator.cs @@ -71,8 +71,7 @@ public class DefaultTwoDimensionalManipulator : DataSetManipulatorBas { if (EqualityComparer.Default.Equals(this.dataSet[this.dataSet.Count - y - 1][x], data)) { - var singleResult = new SearchResult(); - singleResult.DataIndex = new DefaultPositionalDataIndex(x, y); + var singleResult = new SearchResult(new DefaultPositionalDataIndex(x, y)); results.Add(singleResult); } }