Table of Contents

Class Utils

Namespace
Tlumach.Base
Assembly
Tlumach.Base.dll

Contains helper functions, usable across the library.

public static class Utils
Inheritance
Utils
Inherited Members

Fields

C_BACKSLASH

public const char C_BACKSLASH = '\\'

Field Value

char

C_DOUBLE_QUOTE

public const char C_DOUBLE_QUOTE = '"'

Field Value

char

C_SINGLE_QUOTE

public const char C_SINGLE_QUOTE = '\''

Field Value

char

KEY_DECIMAL_DIGITS

public const string KEY_DECIMAL_DIGITS = "decimalDigits"

Field Value

string

KEY_LOCALE

public const string KEY_LOCALE = "locale"

Field Value

string

KEY_NAME

public const string KEY_NAME = "name"

Field Value

string

KEY_SYMBOL

public const string KEY_SYMBOL = "symbol"

Field Value

string

S_BACKSLASH

public const string S_BACKSLASH = "\\"

Field Value

string

S_DOUBLE_QUOTE

public const string S_DOUBLE_QUOTE = "\""

Field Value

string

S_SINGLE_QUOTE

public const string S_SINGLE_QUOTE = "'"

Field Value

string

Methods

ConvertToDouble(object)

public static double ConvertToDouble(object a)

Parameters

a object

Returns

double

ConvertToLong(object)

public static long ConvertToLong(object a)

Parameters

a object

Returns

long

FormatArbDateTime(object, Placeholder, CultureInfo)

public static string FormatArbDateTime(object value, Placeholder placeholder, CultureInfo culture)

Parameters

value object
placeholder Placeholder
culture CultureInfo

Returns

string

FormatArbNumber(ref int, object, Func<string, int, (object?, int)>, Placeholder, string, CultureInfo)

public static string FormatArbNumber(ref int placeholderIndex, object value, Func<string, int, (object?, int)> getPlaceholderValueFunc, Placeholder placeholder, string placeholderContentTail, CultureInfo culture)

Parameters

placeholderIndex int
value object
getPlaceholderValueFunc Func<string, int, (object, int)>
placeholder Placeholder
placeholderContentTail string
culture CultureInfo

Returns

string

FormatArbString(ref int, object, Func<string, int, (object?, int)>, string, CultureInfo)

public static string FormatArbString(ref int placeholderIndex, object value, Func<string, int, (object?, int)> getPlaceholderValueFunc, string placeholderContentTail, CultureInfo culture)

Parameters

placeholderIndex int
value object
getPlaceholderValueFunc Func<string, int, (object, int)>
placeholderContentTail string
culture CultureInfo

Returns

string

FormatArbUnknownPlaceholder(ref int, object, Func<string, int, (object?, int)>, string, CultureInfo)

public static string FormatArbUnknownPlaceholder(ref int placeholderIndex, object value, Func<string, int, (object?, int)> getPlaceholderValueFunc, string placeholderContentTail, CultureInfo culture)

Parameters

placeholderIndex int
value object
getPlaceholderValueFunc Func<string, int, (object, int)>
placeholderContentTail string
culture CultureInfo

Returns

string

GetLeadingNonNegativeNumber(string, out int)

Extracts the number from a string when the string starts with a positive decimal number.

public static int GetLeadingNonNegativeNumber(string text, out int charsUsed)

Parameters

text string

The text to extract the number from.

charsUsed int

The number of characters used from text to parse as a number.

Returns

int

The extracted number or -1 in the case when a number was not extracted.

IsBoxedIntegerNumber(object?)

Checks if the argument is of a integer type.

public static bool IsBoxedIntegerNumber(object? obj)

Parameters

obj object

An object to check.

Returns

bool

true if obj is a number and false otherwise.

IsBoxedNumber(object?)

Checks if the argument is of a numeric type.

public static bool IsBoxedNumber(object? obj)

Parameters

obj object

An object to check.

Returns

bool

true if obj is a number and false otherwise.

IsIdentifier(string?)

public static bool IsIdentifier(string? value)

Parameters

value string

Returns

bool

IsIdentifierWithDots(string?)

public static bool IsIdentifierWithDots(string? value)

Parameters

value string

Returns

bool

ParseDate(string, string)

public static DateTime ParseDate(string date, string format)

Parameters

date string
format string

Returns

DateTime

ParseDateISO8601(string?)

public static DateTime? ParseDateISO8601(string? date)

Parameters

date string

Returns

DateTime?

ReadFileFromDisk(string)

public static string? ReadFileFromDisk(string filename)

Parameters

filename string

Returns

string

ReadFileFromDisk(string, string?, string?)

public static string? ReadFileFromDisk(string filename, string? baseDirectory, string? baseDirectory2)

Parameters

filename string
baseDirectory string
baseDirectory2 string

Returns

string

ReadFileFromResource(Assembly, string)

public static string? ReadFileFromResource(Assembly assembly, string filename)

Parameters

assembly Assembly
filename string

Returns

string

ReadFileFromResource(Assembly, string, string?, string?)

public static string? ReadFileFromResource(Assembly assembly, string filename, string? baseDirectory, string? baseDirectory2)

Parameters

assembly Assembly
filename string
baseDirectory string
baseDirectory2 string

Returns

string

TryGetPropertyValue(object, string, out object?)

public static bool TryGetPropertyValue(object obj, string propertyName, out object? value)

Parameters

obj object
propertyName string
value object

Returns

bool

UnescapeString(string)

Decodes escaping used in JSON and TOML strings.

public static string UnescapeString(string value)

Parameters

value string

original string to decode.

Returns

string

a decoded string.