void ActOnRowsCore(Action <IRowLocation, IRow> action, IColumnLocation currentLoc) { _content.Act(f, g); void f(IEnumerable <IRow> rows) { var rowArray = rows.Select(row => new Row(row)).ToArray(); var rowCount = rowArray.Length; for (int i = 0; i < rowCount; i++) { action(currentLoc.NestOpen(i), rowArray[i]); var colArray = rowArray[i].Columns.Select(col => new Column(col)).ToArray(); var colCount = colArray.Length; for (int j = 0; j < colCount; j++) { colArray[j].ActOnRowsCore(action, currentLoc.Nest(i, j)); } } } void g(object obj) { } }
IEnumerable <T> ProcessRowsCore <T>(Func <IRowLocation, IRow, T> func, IColumnLocation currentLoc) { return(_content.Extract(f, g)); IEnumerable <T> f(IEnumerable <IRow> rows) { var results = new List <T>(); var rowArray = rows.Select(row => new Row(row)).ToArray(); var rowCount = rowArray.Length; for (int i = 0; i < rowCount; i++) { results.Add(func(currentLoc.NestOpen(i), rowArray[i])); var colArray = rowArray[i].Columns.Select(col => new Column(col)).ToArray(); var colCount = colArray.Length; for (int j = 0; j < colCount; j++) { results.AddRange(colArray[j].ProcessRowsCore(func, currentLoc.Nest(i, j))); } } return(results); } IEnumerable <T> g(object obj) => Array.Empty <T>(); }