Class StringExtensions
String extension methods
Inherited Members
Namespace: PayrollEngine.Client.Scripting
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public static class StringExtensions
Fields
View SourceCaseFieldSlotSeparator
The case field slot separator
Declaration
public static readonly char CaseFieldSlotSeparator
Field Value
| Type | Description |
|---|---|
| char |
DateAttributePrefix
Prefix for date attribute fields
Declaration
public static readonly string DateAttributePrefix
Field Value
| Type | Description |
|---|---|
| string |
NumericAttributePrefix
Prefix for numeric attribute fields
Declaration
public static readonly string NumericAttributePrefix
Field Value
| Type | Description |
|---|---|
| string |
RelatedCaseSeparator
The related case separator
Declaration
public static readonly char RelatedCaseSeparator
Field Value
| Type | Description |
|---|---|
| char |
TextAttributePrefix
Prefix for text attribute fields
Declaration
public static readonly string TextAttributePrefix
Field Value
| Type | Description |
|---|---|
| string |
Methods
View SourceContainsCsvToken(string, string, char)
Test for a CSV token
Declaration
public static bool ContainsCsvToken(this string source, string token, char separator = ',')
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | The source value |
| string | token | The token to search |
| char | separator | The token separator |
Returns
| Type | Description |
|---|---|
| bool | True if the token is available |
ConvertJson<T>(string, T)
Convert string to JSON value
Declaration
public static T ConvertJson<T>(this string json, T defaultValue = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | json | |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The converted value |
Type Parameters
| Name | Description |
|---|---|
| T |
EnsureEnd(string, string)
Ensures an ending suffix
Declaration
public static string EnsureEnd(this string source, string suffix)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | |
| string | suffix | The suffix to add |
Returns
| Type | Description |
|---|---|
| string | The string with suffix |
EnsureEnd(string, string, StringComparison)
Ensures an ending suffix
Declaration
public static string EnsureEnd(this string source, string suffix, StringComparison comparison)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | |
| string | suffix | The suffix to add |
| StringComparison | comparison | The comparison culture |
Returns
| Type | Description |
|---|---|
| string | The string with suffix |
EnsureStart(string, string)
Ensures a start prefix
Declaration
public static string EnsureStart(this string source, string prefix)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | |
| string | prefix | The prefix to add |
Returns
| Type | Description |
|---|---|
| string | The string with prefix |
EnsureStart(string, string, StringComparison)
Ensures a start prefix
Declaration
public static string EnsureStart(this string source, string prefix, StringComparison comparison)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | |
| string | prefix | The prefix to add |
| StringComparison | comparison | The comparison culture |
Returns
| Type | Description |
|---|---|
| string | The string with prefix |
GetLocalization(string, Dictionary<string, string>, string)
Gets the localized text
Declaration
public static string GetLocalization(this string culture, Dictionary<string, string> localizations, string defaultValue = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | The culture name |
| Dictionary<string, string> | localizations | The localizations |
| string | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| string | The localized text, the default value in case of absent language |
ObjectValueJson<T>(string, string, T)
Convert JSON value
Declaration
public static T ObjectValueJson<T>(this string json, string objectKey, T defaultValue = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | json | |
| string | objectKey | The object key |
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The converted value |
Type Parameters
| Name | Description |
|---|---|
| T |
RemoveFromEnd(string, string)
Remove suffix from string
Declaration
public static string RemoveFromEnd(this string source, string suffix)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | |
| string | suffix | The suffix to remove |
Returns
| Type | Description |
|---|---|
| string | The string without the ending suffix |
RemoveFromEnd(string, string, StringComparison)
Remove suffix from string
Declaration
public static string RemoveFromEnd(this string source, string suffix, StringComparison comparison)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | |
| string | suffix | The suffix to remove |
| StringComparison | comparison | The comparison culture |
Returns
| Type | Description |
|---|---|
| string | The string without the ending suffix |
RemoveFromStart(string, string)
Remove prefix from string
Declaration
public static string RemoveFromStart(this string source, string prefix)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | |
| string | prefix | The prefix to remove |
Returns
| Type | Description |
|---|---|
| string | The string without suffix |
RemoveFromStart(string, string, StringComparison)
Remove prefix from string
Declaration
public static string RemoveFromStart(this string source, string prefix, StringComparison comparison)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source | |
| string | prefix | The prefix to remove |
| StringComparison | comparison | The comparison culture |
Returns
| Type | Description |
|---|---|
| string | The string without the starting prefix |
RemoveSpecialCharacters(string)
Remove all special characters
Declaration
public static string RemoveSpecialCharacters(this string source)
Parameters
| Type | Name | Description |
|---|---|---|
| string | source |
Returns
| Type | Description |
|---|---|
| string | The source value without special characters |
ToCaseRelationKey(string, string)
Extract related cases from a case relation string, format is 'sourceCaseName:targetCaseName'
Declaration
public static string ToCaseRelationKey(this string caseRelation, string targetCaseName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | caseRelation | |
| string | targetCaseName | The target case name |
Returns
| Type | Description |
|---|---|
| string | The related cases a tuple: item1=source case, item2=target case |
ToDateAttributeField(string)
To date attribute field name
Declaration
public static string ToDateAttributeField(this string attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| string | attribute |
Returns
| Type | Description |
|---|---|
| string | String starting uppercase |
ToNumericAttributeField(string)
To numeric attribute field name
Declaration
public static string ToNumericAttributeField(this string attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| string | attribute |
Returns
| Type | Description |
|---|---|
| string | String starting uppercase |
ToRelatedCaseNames(string)
Extract related cases from a case relation string, format is 'sourceCaseName:targetCaseName'
Declaration
public static Tuple<string, string> ToRelatedCaseNames(this string caseRelation)
Parameters
| Type | Name | Description |
|---|---|---|
| string | caseRelation |
Returns
| Type | Description |
|---|---|
| Tuple<string, string> | The related cases a tuple: item1=source case, item2=target case |
ToTextAttributeField(string)
To text attribute field name
Declaration
public static string ToTextAttributeField(this string attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| string | attribute |
Returns
| Type | Description |
|---|---|
| string | String starting uppercase |