Class StringExtensions
Inheritance
Inherited Members
Namespace: EPiServer.Commerce.Extensions
Assembly: EPiServer.Business.Commerce.dll
Version: 12.17.2Syntax
public static class StringExtensions
Methods
ContainsIgnoreCase(String, String)
Determines whether the specified source contains value incasesensitive.
Declaration
public static bool ContainsIgnoreCase(this string source, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source. |
System.String | value | The value. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Argument Null Exception when soure is null or value is null |
FormatContentText(String)
Formats content text for HTML output
Declaration
public static string FormatContentText(this string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to format |
Returns
Type | Description |
---|---|
System.String | The formatted text |
JavascriptEncode(String)
Gets the string that is suitable for use in client script
Declaration
public static string JavascriptEncode(this string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source. |
Returns
Type | Description |
---|---|
System.String | The encoded string |
StripPreviewText(String, Int32)
Strips a text to a given length without splitting the last word.
Declaration
public static string StripPreviewText(this string source, int maxLength)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source string. |
System.Int32 | maxLength | Max length of the text |
Returns
Type | Description |
---|---|
System.String | A shortened version of the given string |
Remarks
Will return empty string if input is null or empty
ToHtmlEncoded(String)
Get the string that is suitable for display on web page
Declaration
public static string ToHtmlEncoded(this string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source. |
Returns
Type | Description |
---|---|
System.String | the encoded string |
ToJavaScriptEncoded(String)
Get the string that is suitable for use in client script
Declaration
public static string ToJavaScriptEncoded(this string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source. |
Returns
Type | Description |
---|---|
System.String | the encoded string |
ToShorten(String)
If a string is too long (exceed shortStringSize), this function shorten it.
Declaration
public static string ToShorten(this string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source. |
Returns
Type | Description |
---|---|
System.String | shorten string |
ToShorten(String, Int32, Boolean)
If a string is too long (exceed shortStringSize), this function shorten it.
Declaration
public static string ToShorten(this string source, int maxSize, bool useDotDotDot)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source. |
System.Int32 | maxSize | Max size of the returned string. If maxSize is negative, return string.Empty |
System.Boolean | useDotDotDot | use trailing ... (triple dot) or not |
Returns
Type | Description |
---|---|
System.String | shorten string |