C# Class EnergyTrading.Extensions.StringExtensions

Exibir arquivo Open project: RWE-Nexus/EnergyTrading-Core

Public Methods

Method Description
AppendValueToEndIfMissing ( this source, string value ) : string

Append the value to the source if the source is not null/whitespace and the source does not end with the value.

DefaultIfNullOrEmpty ( this source, string defaultValue ) : string

Return the default value if the source value is null or empty.

Matches ( this validValues, string itemToMatch ) : bool

checks to see if a supplied string matches with any item in the list allows for the following simple logic all currently case-insensitive * or *.* => match all items *xxx or *.xxx => EndsWith("xxx") xxx* or xxx.* => StartsWith("xxx") *xxx* or *.xxx.* => Contains("xxx") xxx => string.Compare() == 0

Matches ( this validValues, string itemToMatch, int &noOfMatchedCharacters ) : bool

checks to see if a supplied string matches with any item in the list allows for the following simple logic all currently case-insensitive * or *.* => match all items *xxx or *.xxx => EndsWith("xxx") xxx* or xxx.* => StartsWith("xxx") *xxx* or *.xxx.* => Contains("xxx") xxx => string.Compare() == 0

Method Details

AppendValueToEndIfMissing() public static method

Append the value to the source if the source is not null/whitespace and the source does not end with the value.
public static AppendValueToEndIfMissing ( this source, string value ) : string
source this Value to check.
value string Value to append
return string

DefaultIfNullOrEmpty() public static method

Return the default value if the source value is null or empty.
public static DefaultIfNullOrEmpty ( this source, string defaultValue ) : string
source this Value to check
defaultValue string Default value
return string

Matches() public static method

checks to see if a supplied string matches with any item in the list allows for the following simple logic all currently case-insensitive * or *.* => match all items *xxx or *.xxx => EndsWith("xxx") xxx* or xxx.* => StartsWith("xxx") *xxx* or *.xxx.* => Contains("xxx") xxx => string.Compare() == 0
public static Matches ( this validValues, string itemToMatch ) : bool
validValues this the list of expressions to match against
itemToMatch string the string to match
return bool

Matches() public static method

checks to see if a supplied string matches with any item in the list allows for the following simple logic all currently case-insensitive * or *.* => match all items *xxx or *.xxx => EndsWith("xxx") xxx* or xxx.* => StartsWith("xxx") *xxx* or *.xxx.* => Contains("xxx") xxx => string.Compare() == 0
public static Matches ( this validValues, string itemToMatch, int &noOfMatchedCharacters ) : bool
validValues this the list of expressions to match against
itemToMatch string the string to match
noOfMatchedCharacters int out parameter that returns the number of characters that was actually matched
return bool