private GetMaxValueLength ( IEnumerator enumerator ) : int | ||
enumerator | IEnumerator | Enumerator which can be used to iterate through values for which maximum length is calculated. |
리턴 | int |
/// <summary> /// Iterates through all values in the matrix or jagged array and finds maximum length required /// to show any of the values contained. /// </summary> /// <param name="array">Matrix or jagged array through which this method will iterate.</param> /// <returns>Number of characters sufficient to receive any formatted value contained in <paramref name="array" />.</returns> private int GetMaxValueLength(Array array) { var maxLength = 0; if (IsMultiLinedFormat) { var sfi = new ScalarFormatInfo(this); sfi.ShowDataType = false; sfi.ShowInstanceName = false; if (array.Rank == 2) { maxLength = sfi.GetMaxValueLength(array.GetEnumerator()); } else { // In jagged array we have to iterate through rows manually var rowsEnumerator = array.GetEnumerator(); while (rowsEnumerator.MoveNext()) { var row = (Array)rowsEnumerator.Current; var curMaxLength = sfi.GetMaxValueLength(row.GetEnumerator()); maxLength = Math.Max(maxLength, curMaxLength); } } } return(maxLength); }
/// <summary> /// Iterates through all values in the matrix or jagged array and finds maximum length required /// to show any of the values contained. /// </summary> /// <param name="array">Matrix or jagged array through which this method will iterate.</param> /// <returns>Number of characters sufficient to receive any formatted value contained in <paramref name="array" />.</returns> private int GetMaxValueLength(Array array) { var maxLength = 0; if (IsMultiLinedFormat) { var sfi = new ScalarFormatInfo(this); sfi.ShowDataType = false; sfi.ShowInstanceName = false; if (array.Rank == 2) { maxLength = sfi.GetMaxValueLength(array.GetEnumerator()); } else { // In jagged array we have to iterate through rows manually var rowsEnumerator = array.GetEnumerator(); while (rowsEnumerator.MoveNext()) { var row = (Array) rowsEnumerator.Current; var curMaxLength = sfi.GetMaxValueLength(row.GetEnumerator()); maxLength = Math.Max(maxLength, curMaxLength); } } } return maxLength; }