C# Class Gammtek.Conduit.Text.Formatting.FormatInfoUtils

Stateless static class which exposes methods used to help format strings. This class is internal and cannot be used directly. It is rather used by other classes declared in the SysExpand.Text.Formatting namespace to help format strings.
Afficher le fichier Open project: ME3Explorer/ME3Explorer Class Usage Examples

Méthodes publiques

Свойство Type Description
DefaultMaxFormattedLength int
DefaultMaximumDepth int
DefaultNullFormatted string
InfiniteLoopReport string

Méthodes publiques

Méthode Description
BestTryFormat ( StringBuilder sb, string format, object arg, IEnumerable formatProviders, int &maxLength ) : bool

Attempts to format string which represents given object using series of verbose format providers. Operation ends in success when the first available format provider successfully formats the string. Operation ends in failure if none of the format providers is able to successfully format the string. Use this method to implement two-pass formatting, where in first pass single-lined formatting is attempted with restricted destination string length and in second pass multi-lined formatting without length restrictions is performed.

CombineMaxFormattedLengths ( int length1, int length2 ) : int

Combines two values of the maximum allowed formatted string length.

CopyFormatting ( VerboseFormatInfoBase src, VerboseFormatInfoBase dest ) : VerboseFormatInfoBase

Copies formatting-related property values from one verbose formatter to another one. Use this method to change active formatter so that it formats string in the way in which other formatter would do, but preserving other settings, like indentation details, maximum depth when recursively iterating through contents of the object etc.

CreateMultiLinedFormatter ( ) : VerboseFormatInfoBase

Creates new instance of verbose formatter which can be applied to format multi-lined string without any decorations. This format is applicable to objets of medium complexity. Indentation is performed using multiple whitespace characters.

CreateSimpleFormatter ( ) : VerboseFormatInfoBase

Creates new instance of verbose formatter which can be applied to format simplest possible strings. Only the first level of depth is presented in the formatted string and format is single-lined. This format is applicable to objects of unpredictable complexity, which should be presented by strings of limited length.

CreateSingleLinedFormatter ( ) : VerboseFormatInfoBase

Creates new instance of verbose formatter which formats single-lined strings.

CreateTabbedMultiLinedFormatter ( ) : VerboseFormatInfoBase

Creates new instance of verbose formatter which can be applied to format multi-lined strings without any decorations. This format is applicable to objects of medium complexity. Indentation is performed using horizontal tab characters.

CreateTreeMultiLinedFromatter ( ) : VerboseFormatInfoBase

Creates new instance of verbose formatter which can be applied to format multi-lined string which is decorated as to resemble the look of a tree structure. This format is applicable to complex objects.

ReportInfiniteLoop ( StringBuilder sb, object arg, string argName, int &maxLength ) : bool

Appends information that specified argument produces infinite loop to the given string builder.

TryAppendChar ( VerboseFormatInfoBase formatter, StringBuilder sb, char c, bool success, int &maxLength ) : bool

Tries to append character to the string builder within given amount of characters allowed. Always succeeds in multi-lined formatters.

TryAppendSpaceIfNeeded ( VerboseFormatInfoBase formatter, StringBuilder sb, bool success, int &maxLength ) : bool

Tries to append single white space if string builder doesn't end with space or new line character. Use this method to separate successive items appended to string builder.

TryAppendString ( VerboseFormatInfoBase formatter, StringBuilder sb, string s, bool success, int &maxLength ) : bool

Tries to append string to the string builder within given amount of characters allowed. Always succeeds in multi-lined formatters.

Method Details

BestTryFormat() public static méthode

Attempts to format string which represents given object using series of verbose format providers. Operation ends in success when the first available format provider successfully formats the string. Operation ends in failure if none of the format providers is able to successfully format the string. Use this method to implement two-pass formatting, where in first pass single-lined formatting is attempted with restricted destination string length and in second pass multi-lined formatting without length restrictions is performed.
public static BestTryFormat ( StringBuilder sb, string format, object arg, IEnumerable formatProviders, int &maxLength ) : bool
sb StringBuilder String builder to which formatted string is appended.
format string Format string containing formatting specifications.
arg object An object to format.
formatProviders IEnumerable /// Series of format providers which are contacted one at a time until the first performs /// formatting successfully. ///
maxLength int /// Maximum number of characters allowed to the formatter. Formatting will fail (and return false) /// if this number of characters is breached. Multi-lined formatters will ignore this parameter. /// Negative value indicates that formatter has unlimited space available. /// On output contains remaining number of characters available. ///
Résultat bool

CombineMaxFormattedLengths() public static méthode

Combines two values of the maximum allowed formatted string length.
public static CombineMaxFormattedLengths ( int length1, int length2 ) : int
length1 int First maximum formatted string length; negative value indicates infinite allowed length.
length2 int Second maximum formatted string length; negative value indicates infinite allowed length.
Résultat int

CopyFormatting() public static méthode

Copies formatting-related property values from one verbose formatter to another one. Use this method to change active formatter so that it formats string in the way in which other formatter would do, but preserving other settings, like indentation details, maximum depth when recursively iterating through contents of the object etc.
public static CopyFormatting ( VerboseFormatInfoBase src, VerboseFormatInfoBase dest ) : VerboseFormatInfoBase
src VerboseFormatInfoBase Formatter from which formatting property values are copied.
dest VerboseFormatInfoBase Formatter into which formatting property values are copied.
Résultat VerboseFormatInfoBase

CreateMultiLinedFormatter() public static méthode

Creates new instance of verbose formatter which can be applied to format multi-lined string without any decorations. This format is applicable to objets of medium complexity. Indentation is performed using multiple whitespace characters.
public static CreateMultiLinedFormatter ( ) : VerboseFormatInfoBase
Résultat VerboseFormatInfoBase

CreateSimpleFormatter() public static méthode

Creates new instance of verbose formatter which can be applied to format simplest possible strings. Only the first level of depth is presented in the formatted string and format is single-lined. This format is applicable to objects of unpredictable complexity, which should be presented by strings of limited length.
public static CreateSimpleFormatter ( ) : VerboseFormatInfoBase
Résultat VerboseFormatInfoBase

CreateSingleLinedFormatter() public static méthode

Creates new instance of verbose formatter which formats single-lined strings.
public static CreateSingleLinedFormatter ( ) : VerboseFormatInfoBase
Résultat VerboseFormatInfoBase

CreateTabbedMultiLinedFormatter() public static méthode

Creates new instance of verbose formatter which can be applied to format multi-lined strings without any decorations. This format is applicable to objects of medium complexity. Indentation is performed using horizontal tab characters.
public static CreateTabbedMultiLinedFormatter ( ) : VerboseFormatInfoBase
Résultat VerboseFormatInfoBase

CreateTreeMultiLinedFromatter() public static méthode

Creates new instance of verbose formatter which can be applied to format multi-lined string which is decorated as to resemble the look of a tree structure. This format is applicable to complex objects.
public static CreateTreeMultiLinedFromatter ( ) : VerboseFormatInfoBase
Résultat VerboseFormatInfoBase

ReportInfiniteLoop() public static méthode

Appends information that specified argument produces infinite loop to the given string builder.
public static ReportInfiniteLoop ( StringBuilder sb, object arg, string argName, int &maxLength ) : bool
sb StringBuilder String builder to which information about the argument is appended.
arg object /// Value which has already been appended to in the current line of /// references and should not be visited again or infinite loop would be formed. ///
argName string Optional name of the instance which is reported, if available.
maxLength int /// Maximum number of characters allowed to the formatter. Formatting will fail (and return false) /// if this number of characters is breached. Multi-lined formatters will ignore this parameter. /// Negative value indicates that formatter has unlimited space available. On output contains remaining number of characters available. ///
Résultat bool

TryAppendChar() public static méthode

Tries to append character to the string builder within given amount of characters allowed. Always succeeds in multi-lined formatters.
public static TryAppendChar ( VerboseFormatInfoBase formatter, StringBuilder sb, char c, bool success, int &maxLength ) : bool
formatter VerboseFormatInfoBase Formatter which has requested character to be appended.
sb StringBuilder String builder to which string should be appended.
c char Character which should be appended.
success bool /// Indicates whether appending operations this far have been successful (true) /// or some of the previous append operations has already failed (false). If false, appending will not be attempted. ///
maxLength int /// On input contains maximum number of characters that are allowed to be appended to the string builder. /// On output indicates remaining character positions allowed before appending will fail. ///
Résultat bool

TryAppendSpaceIfNeeded() public static méthode

Tries to append single white space if string builder doesn't end with space or new line character. Use this method to separate successive items appended to string builder.
public static TryAppendSpaceIfNeeded ( VerboseFormatInfoBase formatter, StringBuilder sb, bool success, int &maxLength ) : bool
formatter VerboseFormatInfoBase Formatter which has requested character to be appended.
sb StringBuilder String builder to which whitespace is appended.
success bool /// Indicates whether appending operations this far have been successful (true) /// or some of the previous append operations has already failed (false). If false, appending will not be attempted. ///
maxLength int /// Maximum number of characters allowed to the formatter. Formatting will fail (and return false) /// if this number of characters is breached. Multi-lined formatters will ignore this parameter. /// Negative value indicates that formatter has unlimited space available. On output contains remaining number of characters available. ///
Résultat bool

TryAppendString() public static méthode

Tries to append string to the string builder within given amount of characters allowed. Always succeeds in multi-lined formatters.
public static TryAppendString ( VerboseFormatInfoBase formatter, StringBuilder sb, string s, bool success, int &maxLength ) : bool
formatter VerboseFormatInfoBase Formatter which has requested character to be appended.
sb StringBuilder String builder to which string should be appended.
s string String which should be appended.
success bool /// Indicates whether appending operations this far have been successful (true) /// or some of the previous append operations has already failed (false). If false, appending will not be attempted. ///
maxLength int /// On input contains maximum number of characters that are allowed to be appended to the string builder. /// On output indicates remaining character positions allowed before appending will fail. ///
Résultat bool

Property Details

DefaultMaxFormattedLength public_oe static_oe property

Default maximum allowed length of the single-lined string produced by verbose format providers.
public static int DefaultMaxFormattedLength
Résultat int

DefaultMaximumDepth public_oe static_oe property

Maximum depth applied to formatting if no other depth is specified.
public static int DefaultMaximumDepth
Résultat int

DefaultNullFormatted public_oe static_oe property

Default string shown when null value should be represented.
public static string DefaultNullFormatted
Résultat string

InfiniteLoopReport public_oe static_oe property

String used to report circular reference when formatting string.
public static string InfiniteLoopReport
Résultat string