Class CultureDataFormatter
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Inherited Members
Namespace: SuperOffice.CRM.Globalization
Assembly: SuperOffice.Plugins.dll
Syntax
public static class CultureDataFormatter
Remarks
Fields
BeginTag
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string BeginTag = "["
Field Value
| Type | Description |
|---|---|
| string |
Remarks
BinaryMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string BinaryMarker = "B"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
DateMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string DateMarker = "D"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
DateTimeMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string DateTimeMarker = "DT"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
DoubleMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string DoubleMarker = "F"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
EndTag
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string EndTag = "]"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
IntArrMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string IntArrMarker = "A"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
IntMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string IntMarker = "I"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
MarkerSeparator
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const char MarkerSeparator = ':'
Field Value
| Type | Description |
|---|---|
| char |
Remarks
MoneyMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string MoneyMarker = "M"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
TimeMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string TimeMarker = "T"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
TimeSpanMarker
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public const string TimeSpanMarker = "TS"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
Methods
AddColon(string)
Add a colon to a string if it was not already there, strip any whitespace
Declaration
public static string AddColon(string label)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | String to process |
Returns
| Type | Description |
|---|---|
| string | Original string, now guaranteed to end in exactly one colon |
Remarks
AddTerminator(string, string)
Add a terminator to a string. The string is first stripped, then the terminator is added at the end with no whitespace.
Declaration
public static string AddTerminator(string label, string terminator)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | String to process |
| string | terminator | Terminator to add |
Returns
| Type | Description |
|---|---|
| string | String, now ending with terminator and no white space |
Remarks
CompareEncoded(string, string)
Compare two encoded strings, by parsing them into their underlying data datatype and comparing those
Declaration
public static int CompareEncoded(string x, string y)
Parameters
| Type | Name | Description |
|---|---|---|
| string | x | Formatted string |
| string | y | Formatted string |
Returns
| Type | Description |
|---|---|
| int | -1, 0 or 1 depending on the ordering relation between x and y |
Remarks
Encode(object)
Encode a object based on type. Types supported: DateTime, Double, Integer, String and Boolean
Declaration
public static string Encode(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | Object to be encoded |
Returns
| Type | Description |
|---|---|
| string | Encoded object |
Remarks
EncodeBinary(Stream)
Encode a block of binary data, such as an image
Declaration
public static string EncodeBinary(Stream data)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | data | DateTime whose date component is to be encoded |
Returns
| Type | Description |
|---|---|
| string | Encoded date |
Remarks
EncodeBinary(Stream, bool)
Encode a block of binary data, such as an image
Declaration
public static string EncodeBinary(Stream data, bool performEncode)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | data | Stream be encoded |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded date |
Remarks
EncodeBinaryNoTags(Stream)
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static string EncodeBinaryNoTags(Stream data)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | data |
Returns
| Type | Description |
|---|---|
| string |
Remarks
EncodeDate(DateTime)
Encode a date, without a time part
Declaration
public static string EncodeDate(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime whose date component is to be encoded |
Returns
| Type | Description |
|---|---|
| string | Encoded date |
Remarks
EncodeDate(DateTime, bool)
Encode a date, without a time part. Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeDate(DateTime dateTime, bool performEncode)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime whose date component is to be encoded |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded date |
Remarks
EncodeDateTime(DateTime)
Encode a date, with a time part.
Declaration
public static string EncodeDateTime(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime whose date and time components are to be encoded |
Returns
| Type | Description |
|---|---|
| string | Encoded date/time |
Remarks
EncodeDateTime(DateTime, bool)
Encode a date, with a time part. Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeDateTime(DateTime dateTime, bool performEncode)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime whose date and time components are to be encoded |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded date/time |
Remarks
EncodeDouble(double)
Encode a double (decimal value). On localization, the default number of decimal digits will be used. Also note that currency amounts should use the EncodeMoney method, if the cultural settings for money are to be taken into account (though the currency symbol is NOT used in localization, because we may be displaying non-native currencies).
Declaration
public static string EncodeDouble(double val)
Parameters
| Type | Name | Description |
|---|---|---|
| double | val | Value to be encoded |
Returns
| Type | Description |
|---|---|
| string | Encoded value |
Remarks
EncodeDouble(double, bool)
Encode a double (decimal value). On localization, the default number of decimal digits will be used. Also note that currency amounts should use the EncodeMoney method, if the cultural settings for money are to be taken into account (though the currency symbol is NOT used in localization, because we may be displaying non-native currencies). Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeDouble(double val, bool performEncode)
Parameters
| Type | Name | Description |
|---|---|---|
| double | val | Value to be encoded |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded value |
Remarks
EncodeDouble(double, int)
Encode a double (decimal value), with the given number of decimals. Note that the full precision is included here, but rounded to the given number of decimals on (re)localization. Also note that currency amounts should use the EncodeMoney method, if the cultural settings for money are to be taken into account (though the currency symbol is NOT used in localization, because we may be displaying non-native currencies, saying $ when it's actually € or NOK is silly).
Declaration
public static string EncodeDouble(double val, int decimals)
Parameters
| Type | Name | Description |
|---|---|---|
| double | val | Value to be encoded |
| int | decimals | Final desired number of decimals |
Returns
| Type | Description |
|---|---|
| string | Encoded value |
Remarks
EncodeDouble(double, int, bool)
Encode a double (decimal value), with the given number of decimals. Note that the full precision is included here, but rounded to the given number of decimals on (re)localization. Also note that currency amounts should use the EncodeMoney method, if the cultural settings for money are to be taken into account (though the currency symbol is NOT used in localization, because we may be displaying non-native currencies, saying $ when it's actually € or NOK is silly). Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeDouble(double val, int decimals, bool performEncode)
Parameters
| Type | Name | Description |
|---|---|---|
| double | val | Value to be encoded |
| int | decimals | Final desired number of decimals |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded value |
Remarks
EncodeInt(int)
Encode an integer. Integers are usually not culturally sensitive... but who knows.
Declaration
public static string EncodeInt(int val)
Parameters
| Type | Name | Description |
|---|---|---|
| int | val | Value to encode |
Returns
| Type | Description |
|---|---|
| string | Encoded value |
Remarks
EncodeInt(int, bool)
Encode an integer. Integers are usually not culturally sensitive... but who knows. Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeInt(int val, bool performEncode)
Parameters
| Type | Name | Description |
|---|---|---|
| int | val | Value to encode |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded value |
Remarks
EncodeIntArr(params int[])
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static string EncodeIntArr(params int[] intArr)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | intArr |
Returns
| Type | Description |
|---|---|
| string |
Remarks
EncodeMoney(double)
Encode a double, for displaying it as money. The local user settings for currency, EXCEPT the currency symbol, will be used for display. No currency symbol will be display regardless of settings.
Declaration
public static string EncodeMoney(double val)
Parameters
| Type | Name | Description |
|---|---|---|
| double | val | Value to encode |
Returns
| Type | Description |
|---|---|
| string | Encoded value |
Remarks
EncodeMoney(double, bool)
Encode a double, for displaying it as money. The local user settings for currency, EXCEPT the currency symbol, will be used for display. No currency symbol will be display regardless of settings. Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeMoney(double val, bool performEncode)
Parameters
| Type | Name | Description |
|---|---|---|
| double | val | Value to encode |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded value |
Remarks
EncodeTime(DateTime)
Encode a time, without a date part
Declaration
public static string EncodeTime(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime whose time component is to be encoded |
Returns
| Type | Description |
|---|---|
| string | Encoded time |
Remarks
EncodeTime(DateTime, bool)
Encode a time, without a date part. Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeTime(DateTime dateTime, bool performEncode)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime whose time component is to be encoded |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded time |
Remarks
EncodeTimeSpan(int, bool)
Encode a timespan Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeTimeSpan(int seconds, bool performEncode = true)
Parameters
| Type | Name | Description |
|---|---|---|
| int | seconds | Seconds to be encoded. |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded time |
Remarks
EncodeTimeSpan(TimeSpan, bool)
Encode a timespan, encodes total number of seconds Optionally skip encoding and return an empty string instead.
Declaration
public static string EncodeTimeSpan(TimeSpan timeSpan, bool performEncode = true)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeSpan | TimeSpan to be encoded. |
| bool | performEncode | If true, the input parameter is encoded to string. If false, an empty string is returned instead. This parameter is implemented to streamline coding of optimized field population in the archive providers, where a mode switch may eliminate the need for string-encoded display values. |
Returns
| Type | Description |
|---|---|
| string | Encoded time |
Remarks
FormatFromMetadata(string, FieldMetadataInfo)
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static string FormatFromMetadata(string input, FieldMetadataInfo typeInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| string | input | |
| FieldMetadataInfo | typeInfo |
Returns
| Type | Description |
|---|---|
| string |
Remarks
GetCultureDisplayName(CultureInfo)
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static string GetCultureDisplayName(CultureInfo cultureInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | cultureInfo |
Returns
| Type | Description |
|---|---|
| string |
Remarks
GetReadableTimeSpan(int, bool, string, string, string, string, string)
Convert the time/duration/timespan to a "readable" text - either seconds, or day/hour/minute/second
Declaration
public static string GetReadableTimeSpan(int seconds, bool mostSignificant, string daySignifier = "d", string hourSignifier = "h", string minuteSignifier = "m", string secondSignifier = "s", string zeroSignifier = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | seconds | Total seconds to convert |
| bool | mostSignificant | If true, then only show the most-significant unit; otherwise show d/h/m/s |
| string | daySignifier | The string to use for the day component suffix |
| string | hourSignifier | The string to use for the hour component suffix |
| string | minuteSignifier | The string to use for the minute component suffix |
| string | secondSignifier | The string to use for the second component suffix |
| string | zeroSignifier | The suffix string to use when 0 seconds were passed. Empty string might be returned if this parameter was missing |
Returns
| Type | Description |
|---|---|
| string | Formatted string |
Remarks
GetStringType(string, out string, out int)
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static string GetStringType(string encodedSomething, out string val, out int decimals)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedSomething | |
| string | val | |
| int | decimals |
Returns
| Type | Description |
|---|---|
| string |
Remarks
GetSuperOfficeLanguages()
Get all current supported superoffice languages, by superoffice language code (win legacy)
Declaration
public static IEnumerable<string> GetSuperOfficeLanguages()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> |
Remarks
LocalFormatDate(DateTime)
Format a date (without time) according to current settings
Declaration
public static string LocalFormatDate(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime to be formatted |
Returns
| Type | Description |
|---|---|
| string | Formatted date |
Remarks
LocalFormatDateTime(DateTime)
Format a date with time according to current settings
Declaration
public static string LocalFormatDateTime(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | Datetime to be formatted |
Returns
| Type | Description |
|---|---|
| string | Formatted date and time |
Remarks
LocalFormatDouble(double, int)
Format a double, with the given number of decimal digits; otherwise the current settings will be followed
Declaration
public static string LocalFormatDouble(double val, int decimals)
Parameters
| Type | Name | Description |
|---|---|---|
| double | val | Double to be formatted |
| int | decimals | Desired number of decimals |
Returns
| Type | Description |
|---|---|
| string | Formatted number |
Remarks
LocalFormatInt(int)
Format an integer according to current settings
Declaration
public static string LocalFormatInt(int val)
Parameters
| Type | Name | Description |
|---|---|---|
| int | val | int to be formatted |
Returns
| Type | Description |
|---|---|
| string | Formatted integer |
Remarks
LocalFormatLongDate(DateTime)
Format a long date (without time) according to current settings
Declaration
public static string LocalFormatLongDate(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime to be formatted |
Returns
| Type | Description |
|---|---|
| string | Formatted long date |
Remarks
LocalFormatLongDateTime(DateTime)
Format a long date with a short time according to current settings
Declaration
public static string LocalFormatLongDateTime(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | Datetime to be formatted |
Returns
| Type | Description |
|---|---|
| string | Formatted long date and short time |
Remarks
LocalFormatMoney(double)
Format a double as a currency value, though without a currency symbol. Other local settings for currencies will be followed.
Declaration
public static string LocalFormatMoney(double val)
Parameters
| Type | Name | Description |
|---|---|---|
| double | val | Double to be formatted |
Returns
| Type | Description |
|---|---|
| string | Formatted amount |
Remarks
LocalFormatTime(DateTime)
Format a time without date according to current settings
Declaration
public static string LocalFormatTime(DateTime dateTime)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | dateTime | DateTime to be formatted |
Returns
| Type | Description |
|---|---|
| string | Formatted time, without date |
Remarks
LocalizeEncoded(string)
Take an encoded value of any type, parse it, and reformat it to its localized (current culture) string form
Declaration
public static string LocalizeEncoded(string encodedSomething)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedSomething | Output from one of the Encode methods |
Returns
| Type | Description |
|---|---|
| string | Equivalent, localized value |
Remarks
MapCsLanguageToSuperOfficeLanguage(string)
Convert a language code from cs to SuperOffice language code.
Declaration
public static string MapCsLanguageToSuperOfficeLanguage(string csLang)
Parameters
| Type | Name | Description |
|---|---|---|
| string | csLang |
Returns
| Type | Description |
|---|---|
| string | SuperOffice languagecode or string.empty if none found |
Remarks
MapCultureToSuperOfficeLanguage(string)
Converts .net Culture name ("sv-SE") to SuperOffice language code ("SW").
Declaration
public static string MapCultureToSuperOfficeLanguage(string cultureName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | cultureName | Either a culture name or a SuperOffice language code. |
Returns
| Type | Description |
|---|---|
| string | A SuperOffice language code. (US, NO, SW, DA, FI, FR, GE, IT, NL, SP, PL, RU, CN, CZ, JP, UK, KO, VI, BR, CH) |
Remarks
Converting to a SuperOffice language code twice is harmless.
If unable to determine a mapping, the default is US (English). See also MSDN on culture codes.See Also
MapLCIDToSuperOfficeLanguage(int)
Converts a .net culture LCID to SuperOffice Language Code
Declaration
public static string MapLCIDToSuperOfficeLanguage(int lcid)
Parameters
| Type | Name | Description |
|---|---|---|
| int | lcid | The LCID to convert |
Returns
| Type | Description |
|---|---|
| string | The SuperOffice language code if defined - the two letter iso name if undefined |
Remarks
MapLanguageToCsLanguage(string)
Convert a language code to the language code expected by CS.
Declaration
public static string MapLanguageToCsLanguage(string languageCode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | languageCode |
Returns
| Type | Description |
|---|---|
| string |
Remarks
MapSuperOfficeLanguageToCulture(string)
Converts a SuperOffice language code ("SW") to a neutral .net culture name ("sv")
Declaration
public static string MapSuperOfficeLanguageToCulture(string superOfficeLanguageCode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | superOfficeLanguageCode | SuperOffice language code. (US, NO, SW, DA, FI, FR, GE, IT, NL, SP, PL, RU, CN, CZ, JP, UK, KO, VI, BR, CH) |
Returns
| Type | Description |
|---|---|
| string | .net neutral Culture name, or empty string (invariant culture) if no mapping found |
Remarks
If unable to determine a mapping, the default is US (English).
See also MSDN on culture codes.See Also
ParseEncoded(string)
Inspect the marker and parse the content, returning a strongly typed object (double, int, byte[], DateTime etc)
Declaration
public static object ParseEncoded(string encodedSomething)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedSomething |
Returns
| Type | Description |
|---|---|
| object |
Remarks
ParseEncodedBinary(string)
Parse/decode an encoded binary data block - either with a marker, or just a Base64 encoded string
Declaration
public static byte[] ParseEncodedBinary(string encodedBinary)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedBinary |
Returns
| Type | Description |
|---|---|
| byte[] |
Remarks
ParseEncodedDate(string)
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static DateTime ParseEncodedDate(string encodedDate)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedDate |
Returns
| Type | Description |
|---|---|
| DateTime |
Remarks
ParseEncodedDecimal(string)
Parse "123.4" and "[F:123.4]" into 123.4
Declaration
public static decimal ParseEncodedDecimal(string encodedDecimal)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedDecimal | "123.4" or "[F:123.4]" |
Returns
| Type | Description |
|---|---|
| decimal | The value or an exception if not a decimal |
Remarks
ParseEncodedDouble(string)
Parse "123.4" and "[F:123.4]" into 123.4
Declaration
public static double ParseEncodedDouble(string encodedDouble)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedDouble | "123.4" or "[F:123.4]" |
Returns
| Type | Description |
|---|---|
| double | The value or an exception if not an double |
Remarks
ParseEncodedInt(string)
Parse "123" and "[I:123]" into 123. Parse "abc" into 0. Does not throw, but returns 0.
Declaration
public static int ParseEncodedInt(string encodedInt)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedInt | "123" or "[I:123]" |
Returns
| Type | Description |
|---|---|
| int | The value as int, or 0 if not an integer |
Remarks
ParseEncodedInt(string, bool)
Parse "123" and "[I:123]" into 123.
Declaration
public static int ParseEncodedInt(string encodedInt, bool strictly)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedInt | "123" or "[I:123]" |
| bool | strictly | If true, then throws instead of returning 0 for non-numbers |
Returns
| Type | Description |
|---|---|
| int | The value or an exception if not an integer |
Remarks
ParseEncodedIntArr(string)
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static int[] ParseEncodedIntArr(string encodedIntArr)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedIntArr |
Returns
| Type | Description |
|---|---|
| int[] |
Remarks
ParseEncodedTimeSpan(string, bool)
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static int ParseEncodedTimeSpan(string encodedTimeSpan, bool strictly = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedTimeSpan | |
| bool | strictly |
Returns
| Type | Description |
|---|---|
| int |
Remarks
ParseInlineElements(string, string)
Parses a resource string with inline culture-sensitive data in the text, for instance dates... provided they have been encoded using the CultureDataFormatter in the first place. Multi-language elements are also handled, before any culture-sensitive elements.
Declaration
public static string ParseInlineElements(string resourceString, string cultureName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | resourceString | The string to parse |
| string | cultureName | The cultureName, typically en-US, nb-NO, but also US, NO is accepted |
Returns
| Type | Description |
|---|---|
| string | Parsed resource string. |
Remarks
ParseInlineMultiLanguageString(string, string, int)
Parses the string for multilang strings and uses ParseMultiLanguageString(string, string) to translate the fragment to a culture specific string part
Declaration
public static string ParseInlineMultiLanguageString(string multilangString, string cultureName, int startingIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | multilangString | The multilanguage string to parse:
|
| string | cultureName | The cultureName, typically en-US, nb-NO, but also US, NO is accepted |
| int | startingIndex | The starting index for the parsing |
Returns
| Type | Description |
|---|---|
| string | All culture specific string parts translated, or original string if there is a problem |
Remarks
ParseMultiLanguageString(string, string)
Returns the string part of the specified culture from the multi language string
These strings are typically used in SuperOffice list and description data
Declaration
public static string ParseMultiLanguageString(string multilangString, string cultureName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | multilangString | The multilanguage string to parse:
|
| string | cultureName | The cultureName, typically en-US, nb-NO, but also US, NO is accepted |
Returns
| Type | Description |
|---|---|
| string | Culture specific string part, or original string if there is a problem |
Remarks
This version will also accept strings that have non-multilanguage text before and after the multilanguage block, and even multiple multilanguage blocks (provided there is at least one non-conforming character between them), isolating them and parsing each one separately. Non-conforming text is kept in place in the output.
StripColon(string)
Strip a terminating colon from a string, and any whitespace
Declaration
public static string StripColon(string label)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | String to process |
Returns
| Type | Description |
|---|---|
| string | String, without colon and without leading/trailing whitespace |
Remarks
StripCountrySpecificsFromLanguageName(string)
Converts "English (Zimbabwe)" into plain "English" by removing anything in parenthesis and stripping spaces.
Declaration
public static string StripCountrySpecificsFromLanguageName(string languageName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | languageName | Human readable language name: "Norsk (Bokmål)" or "Francaise" |
Returns
| Type | Description |
|---|---|
| string | Simplified language name with initial capital: "Norsk" or "Francaise" |
Remarks
StripTerminator(string, string)
Strip a terminator from a string. Whitespace is first trimmed from both sides of the string, the terminator is removed if present, and any whitespace now at the end of the string is also removed
Declaration
public static string StripTerminator(string label, string terminator)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | String to process |
| string | terminator | Terminator to remove |
Returns
| Type | Description |
|---|---|
| string | Original string minus terminator |
Remarks
TryParse(string, out DateTime)
Try to parse a string as an encoded or bare InvariantCulture DateTime
Declaration
public static bool TryParse(string encoded, out DateTime result)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encoded | String, either marked with [DT: ] or just a datetime |
| DateTime | result | DateTime value, if return value is true; otherwise MinValue |
Returns
| Type | Description |
|---|---|
| bool | true if parsing succeeded |
Remarks
TryParse(string, out double)
Try to parse a string as an encoded or bare InvariantCulture Double
Declaration
public static bool TryParse(string encoded, out double result)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encoded | String, either marked with [F: ] or just a date |
| double | result | Double value, if return value is true; otherwise 0 |
Returns
| Type | Description |
|---|---|
| bool | true if parsing succeeded |
Remarks
TryParse(string, out int)
Try to parse a string as an encoded or bare InvariantCulture Integer32
Declaration
public static bool TryParse(string encoded, out int result)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encoded | String, either marked with [I: ] or just an integer |
| int | result | Int value, if return value is true; otherwise 0 |
Returns
| Type | Description |
|---|---|
| bool | true if parsing succeeded |
Remarks
TryParse(string, out int[])
This is a helper class designed to encode, parse and reformat culturally sensitive data types between an application server without culture knowledge, and a front-end with such knowledge.
Declaration
public static bool TryParse(string encodedIntArr, out int[] result)
Parameters
| Type | Name | Description |
|---|---|---|
| string | encodedIntArr | |
| int[] | result |
Returns
| Type | Description |
|---|---|
| bool |