GenericExtensions Class

Extension functions for generic types (Strings, Int32's, etc.) or standard items from the System namespaces.

Definition

Namespace: MobileTrack.Common.Extensions
Assembly: MobileTrack.Common (in MobileTrack.Common.dll) Version: 0.7+45c8d9adb5970d727cceec44a5ed61aea0016e50
public static class GenericExtensions
Inheritance
Object    GenericExtensions

Methods

AppendPadded Appends a string to the end of this builder, along with extra whitespace
ConvertLabelToUrl Convert the string to a URL format.
FormatList Formats a list to "w, x, y and z" or "x and y" or "x" format.
FromIsoDateParts Converts ISO date parts to a TimeSpan. Not entirely accurate, as it assumes all months are 30 days and all years are 365 days, but it is a good approximation for many use cases.
FromUrlSafeBase64 Converts a URL-safe Base64 string back to a byte array.
GetAmountOfDigitsInNumber Retrieves the amount of digits in a number.
GetDefaultValue Returns the default value of a type during runtime.
GetInterfaceProperties returns all properties of a type
GetPublicProperties returns all properties of a type
GetTypeOrUnderlying(Expression) Returns the type of the expression, or the underlying type if it's a Nullable type.
GetTypeOrUnderlying(Type) Returns type, or the underlying type if it's a Nullable type.
IsDarkColor Determines if the color is a dark color using its relative luminance.
Useful if we want to use a user-set color value as a background color and then display readable text over it.
IsHex(Char) Checks if a character is a hexadecimal character.
IsHex(String) Checks if a string is a hexadecimal string.
Lerp Performs a lerp operation between two colors and returns the resulting color.
MakeColorFromHex Converts a hex string to a Color
MergeTKey, TValue Merges multiple dictionaries into one.
RemoveAccolades Removes the {{ and }} from a parameter in the template
RemoveAllWhitespace Removes all whitespace, newlines etc. from a string, including whitespace between characters, making it different from Trim
RemoveEntriesByValueTKey, TValue Filters a dictionary by its keys.
TakeLastT Takes the last N items from an IEnumerableT.
ToHex(Byte) Turns a Byte into a HEX-string.
ToHex(Color) Converts a Color to a hex string
ToHex(NullableColor) Converts a nullable Color to a hex string
ToHexString Converts a byte array to a HEX-string.
ToIso8601DateDuration Converts a TimeSpan to an ISO 8601 date duration string.
ToUrlSafeBase64 Converts a byte array to a URL-safe Base64 string.
TrimSpecialCharacters Removes all special characters from a string.
Truncate Truncates a string if it's longer than length, and appends "..." to the end.

Fields

RegexOptions Default regex options for URL regex checking; ignore case (1), compiled (8) and culture invariant (512).

See Also