Ejemplo n.º 1
0
 /// <summary>
 /// Gets the result set as list of string arrays.
 /// </summary>
 /// <param param name="resultSet">The result set to convert to a string array list.</param>
 /// <returns>A list of string arrays representing the result set.</returns>
 public static List<String[]> ResultSetToStringArrayList(ResultSet resultSet) {
   List<string[]> stringArrayList = new List<string[]>();
   stringArrayList.Add(GetColumnLabels(resultSet));
   if (resultSet.rows != null) {
     foreach (Row row in resultSet.rows) {
       stringArrayList.Add(GetRowStringValues(row));
     }
   }
   return stringArrayList;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the column labels for the result set.
 /// </summary>
 /// <param name="resultSet">The result set to get the column labels for.
 /// </param>
 /// <returns>The string array of column labels.</returns>
 public static String[] GetColumnLabels(ResultSet resultSet) {
   List<string> columnLabels = new List<string>();
   foreach (ColumnType column in resultSet.columnTypes) {
     columnLabels.Add(column.labelName);
   }
   return columnLabels.ToArray();
 }
Ejemplo n.º 3
0
    /// <summary>
    /// Gets the result set as a table represenation in the form of:
    ///
    /// <pre>
    /// +-------+-------+-------+
    /// |column1|column2|column3|
    /// +-------+-------+-------+
    /// |value1 |value2 |value3 |
    /// +-------+-------+-------+
    /// |value1 |value2 |value3 |
    /// +-------+-------+-------+
    /// </pre>
    /// </summary>
    /// <param name="resultSet">The result set to display as a string</param>
    /// <returns>The string represenation of result set as a table.</returns>
    public static String ResultSetToString(ResultSet resultSet) {
      StringBuilder resultSetStringBuilder = new StringBuilder();
      List<String[]> resultSetStringArrayList = ResultSetToStringArrayList(resultSet);
      List<int> maxColumnSizes = GetMaxColumnSizes(resultSetStringArrayList);
      string rowTemplate = CreateRowTemplate(maxColumnSizes);
      string rowSeparator = CreateRowSeperator(maxColumnSizes);

      resultSetStringBuilder.Append(rowSeparator);
      for (int i = 0; i < resultSetStringArrayList.Count; i++) {
        resultSetStringBuilder.AppendFormat(rowTemplate, (object[]) resultSetStringArrayList[i]).
            Append(rowSeparator);
      }
      return resultSetStringBuilder.ToString();
    }