// TO DO: should this be a "step"? private List <Row> GetFinalColumns(List <Row> input, List <string> columns, out int rowCount) { var result = new List <Row>(); Row x = null; RowQueryComparer comparer = new RowQueryComparer(); foreach (var row in input) { x = new Row(Guid.Empty); foreach (var value in row.Values) { foreach (var column in columns) { if (value.ColumnName.ToUpper() == column.ToUpper()) { x.AddValue(null, value.Value, value.ColumnName, value.ColumnType); } } } result.Add(x); } var z = new List <Row>(); z = result.Distinct(comparer).ToList(); rowCount = z.Count; return(z); }
public static IEnumerable <Row> AsRowCollection(this IEnumerable <string> collection, Header header, params IParsingValidator[] validators) { var columns = header.Columns(); return(collection .Select(s => { try { var @string = s; Row newRow = new Row(header); foreach (var column in columns) { var value = @string.Substring(column.StartIndex, column.EndIndex); @string = @string.Substring(column.EndIndex); newRow.AddValue(column.Name, value); } return newRow; } catch (Exception ex) { throw new ParseRowException($"Erro ao ler a linha '{s}'.\nOcorreram os seguintes erros:\n{ex.Message}", ex); } }).Where(w => validators.All(a => a.IsValid(w) == ParseResult.Success))); }