Lean
$LEAN_TAG$
|
Provides extension methods for properly parsing and serializing values while properly using an IFormatProvider/CultureInfo when applicable More...
Static Public Member Functions | |
static T | ConvertInvariant< T > (this object value) |
Converts the provided value as T using CultureInfo More... | |
static object | ConvertInvariant (this object value, Type conversionType) |
Converts the provided value as conversionType using CultureInfo More... | |
static string | Invariant (FormattableString formattable) |
Non-extension method alias for FormattableString.Invariant This supports the More... | |
static string | ToStringInvariant (this IConvertible convertible) |
Converts the provided value to a string using CultureInfo More... | |
static string | ToStringInvariant (this IFormattable formattable, string format) |
Formats the provided value using the specified format and CultureInfo More... | |
static string | ToIso8601Invariant (this DateTime dateTime) |
Provides a convenience methods for converting a DateTime to an invariant ISO-8601 string More... | |
static bool | StartsWithInvariant (this string value, string beginning, bool ignoreCase=false) |
Checks if the string starts with the provided beginning using CultureInfo while optionally ignoring case. More... | |
static bool | EndsWithInvariant (this string value, string ending, bool ignoreCase=false) |
Checks if the string ends with the provided ending using CultureInfo while optionally ignoring case. More... | |
static int | IndexOfInvariant (this string value, char character) |
Gets the index of the specified character using StringComparison More... | |
static int | IndexOfInvariant (this string value, string substring, bool ignoreCase=false) |
Gets the index of the specified substring using StringComparison or System.StringComparison.InvariantCultureIgnoreCase when ignoreCase is true More... | |
static int | LastIndexOfInvariant (this string value, string substring, bool ignoreCase=false) |
Gets the index of the specified substring using StringComparison or System.StringComparison.InvariantCultureIgnoreCase when ignoreCase is true More... | |
static T | IfNotNullOrEmpty< T > (this string value, T defaultValue, Func< string, T > func) |
Provides a shorthand for avoiding the more verbose ternary equivalent. Consider the following: More... | |
static T | IfNotNullOrEmpty< T > (this string value, Func< string, T > func) |
Provides a shorthand for avoiding the more verbose ternary equivalent. Consider the following: More... | |
static string | SafeSubstring (this string value, int startIndex, int length) |
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length. More... | |
static string | Truncate (this string value, int maxLength) |
Truncates a string to the specified maximum length More... | |
Provides extension methods for properly parsing and serializing values while properly using an IFormatProvider/CultureInfo when applicable
Definition at line 26 of file StringExtensions.cs.
|
static |
Converts the provided value as T using CultureInfo
Definition at line 36 of file StringExtensions.cs.
|
static |
Converts the provided value as conversionType using CultureInfo
This implementation uses the Convert.ToXXX methods. This causes null values to be converted to the default value for the provided conversionType . This is in contrast to directly calling IConvertible.ToType which results in an InvalidCastException or a FormatException. Since existing code is dependent on this null -> default value conversion behavior, it has been preserved in this method.
Definition at line 51 of file StringExtensions.cs.
|
static |
Non-extension method alias for FormattableString.Invariant This supports the
using static QuantConnect.StringExtensions
syntax and is aimed at ensuring all formatting is piped through this class instead of alternatively piping through directly to FormattableString.Invariant
Definition at line 127 of file StringExtensions.cs.
|
static |
Converts the provided value to a string using CultureInfo
Definition at line 135 of file StringExtensions.cs.
|
static |
Formats the provided value using the specified format and CultureInfo
Definition at line 149 of file StringExtensions.cs.
|
static |
Provides a convenience methods for converting a DateTime to an invariant ISO-8601 string
Definition at line 182 of file StringExtensions.cs.
|
static |
Checks if the string starts with the provided beginning using CultureInfo while optionally ignoring case.
Definition at line 191 of file StringExtensions.cs.
|
static |
Checks if the string ends with the provided ending using CultureInfo while optionally ignoring case.
Definition at line 200 of file StringExtensions.cs.
|
static |
Gets the index of the specified character using StringComparison
Definition at line 208 of file StringExtensions.cs.
|
static |
Gets the index of the specified substring using StringComparison or System.StringComparison.InvariantCultureIgnoreCase when ignoreCase is true
Definition at line 217 of file StringExtensions.cs.
|
static |
Gets the index of the specified substring using StringComparison or System.StringComparison.InvariantCultureIgnoreCase when ignoreCase is true
Definition at line 229 of file StringExtensions.cs.
|
static |
Provides a shorthand for avoiding the more verbose ternary equivalent. Consider the following:
string.IsNullOrEmpty(str) ? (decimal?)null : Convert.ToDecimal(str, CultureInfo.InvariantCulture)
Can be expressed as: str.IfNotNullOrEmpty<decimal?>(s => Convert.ToDecimal(str, CultureInfo.InvariantCulture))
When combined with additional methods from this class, reducing further to a declarative: str.IfNotNullOrEmpty<decimal?>(s => s.ParseDecimalInvariant()) str.IfNotNullOrEmpty<decimal?>(s => s.ConvertInvariant<decimal>())
value The string value to check for null or empty defaultValue The default value to use if null or empty func Function run on non-null string w/ length > 0
Definition at line 256 of file StringExtensions.cs.
|
static |
Provides a shorthand for avoiding the more verbose ternary equivalent. Consider the following:
string.IsNullOrEmpty(str) ? (decimal?)null : Convert.ToDecimal(str, CultureInfo.InvariantCulture)
Can be expressed as: str.IfNotNullOrEmpty<decimal?>(s => Convert.ToDecimal(str, CultureInfo.InvariantCulture))
When combined with additional methods from this class, reducing further to a declarative: str.IfNotNullOrEmpty<decimal?>(s => s.ParseDecimalInvariant()) str.IfNotNullOrEmpty<decimal?>(s => s.ConvertInvariant<decimal>())
value The string value to check for null or empty func Function run on non-null string w/ length > 0
Definition at line 284 of file StringExtensions.cs.
|
static |
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
startIndex The zero-based starting character position of a substring in this instance length The number of characters in the substring
Definition at line 295 of file StringExtensions.cs.
|
static |
Truncates a string to the specified maximum length
value | The string |
maxLength | The maximum allowed string |
Definition at line 324 of file StringExtensions.cs.