Class ReportHelpers
This static class exposes methods to help prepare strings for use on reports.
Inheritance
Inherited Members
Namespace: WizardWrx
Assembly: WizardWrx.Common.dll
Syntax
public static class ReportHelpers
Fields
| Improve this Doc View SourceDOUBLE_SPACE
Overlooked constant - two consecutive spaces.
Declaration
public const string DOUBLE_SPACE = " "
Field Value
Type | Description |
---|---|
System.String |
EMBEDDED_TAB
Tab characters, as they must be entered into resource (.RESX) strings.
Declaration
public const string EMBEDDED_TAB = "\\t"
Field Value
Type | Description |
---|---|
System.String |
OUTPUT_TAB
Tab characters, as they must appear in the string before it can be used.
Declaration
public const string OUTPUT_TAB = "\\t"
Field Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceDetailTemplateFromLabels(String)
Given a formatted string for a label row, generate a format string for the corresponding detail row.
Declaration
public static string DetailTemplateFromLabels(string pstrReportLabels)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrReportLabels | Label string for which to generate a detail string. |
Returns
Type | Description |
---|---|
System.String | String, for use with string.Format method. |
DetailTemplateFromLabels(String, Char)
Given a formatted string for a label row, generate a format string for the corresponding detail row.
Declaration
public static string DetailTemplateFromLabels(string pstrReportLabels, char pchrFieldSeparator)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrReportLabels | Label string for which to generate a detail string. |
System.Char | pchrFieldSeparator | Character to use in lieu of TAB as field separator. |
Returns
Type | Description |
---|---|
System.String | String, for use with string.Format method. |
MaxStringLength<T>(List<T>)
Given an array of objects of any type, return the length of the longest string made from them. See Remarks.
Declaration
public static int MaxStringLength<T>(List<T> plstObjs)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<T> | plstObjs | This argument expects an array of objects, which may be of different kinds. Since the generic List class has a constructor that takes an array, which it copies into the new list that it returns, you can use this method to process arrays by specifying a new List of the appropriate type for this argument. For additional information, please see the Remarks section. |
Returns
Type | Description |
---|---|
System.Int32 | The return value is the length of the longest string made from the objects in the input array. Since it is intended for use with the PadRight method on a string, it is cast to int. See Remarks. |
Type Parameters
Name | Description |
---|---|
T | This is a generic method; its argument may be of any type. This method needs only its ToString method. |
Remarks
The goal of this routine is to determine the maximum number of characters required to represent any of a collection of objects such as labels or members of an enumerated type. This method has at least three use cases.
Pad the strings to a uniform length, so that all of a set of labeled values aligns vertically.
Construct a key from several substrings, such that the substrings are of uniform length, and the keys can be grouped by any of the leading substrings, and ordered by the values of the last substring.
Construct a composite format string that reserves enough room for the widest item in the list, so that whatever follows it on a report line aligns vertically.
Examples
The following example returns the length of the longest string contained in array astrLinesFromFile, an array of strings.
int intLogestLine = WizardWrx.ReportHelpers.MaxStringLength ( new List<string> ( astrLinesFromFile ) );
Note use of the List constructor, which transforms the array into a disposable generic List.