private static List <List <string> > ExtractData(CronusReference.DataTuple[] values) { bool isFirst = true; List <List <string> > totals = new List <List <string> >(); for (int i = 0; i < values.Length; i++) { CronusReference.DataTuple t = values[i]; List <string> array2 = new List <string>(); List <string> columns2 = new List <string>(); //string[] array = new string[t.Count]; //string[] columns = new string[t.Count]; if (isFirst) { totals.Add(columns2); isFirst = false; } for (int j = 0; j < t.Count; j++) { SerializableKeyValuePairOfStringString s = t.ElementAt(j); columns2.Add(s.Key); array2.Add(s.Value); } totals.Add(array2); } return(totals); }
public static string ToString(DataTuple[] tuples) { int[] longestColumnLength = null; bool isFirst = true; List <List <string> > totals = new List <List <string> >(); for (int i = 0; i < tuples.Length; i++) { CronusReference.DataTuple t = tuples[i]; if (longestColumnLength == null) { longestColumnLength = new int[t.Count]; } List <string> array = new List <string>(); List <string> columns = new List <string>(); if (isFirst) { totals.Add(columns); isFirst = false; } for (int j = 0; j < t.Count; j++) { SerializableKeyValuePairOfStringString s = t.ElementAt(j); // Figure out max column length if (s.Value != null) { longestColumnLength[j] = Math.Max(s.Value.Length, longestColumnLength[j]); } columns.Add(s.Key); array.Add(s.Value); } totals.Add(array); } // Is the column name the longest value in the column? for (int i = 0; i < totals[0].Count; i++) { string column = totals[0][i]; if (column != null) { longestColumnLength[i] = Math.Max(column.Length, longestColumnLength[i]); } } return(GenerateOutputWithColumns(totals, longestColumnLength)); }