Skip to content

Utils.Extensions

robbyxp1 edited this page Feb 9, 2025 · 5 revisions

Extensions Class

Extension class helpers for JSON system.

public static class Extensions

Inheritance System.Object 🡒 Extensions


Methods


Extensions.AlwaysQuoteString(string) Method

Always quote the string, and replace " with "

public static string AlwaysQuoteString(this string obj);
Parameters

obj System.String
string

Returns

System.String
quoted string


Extensions.AppendEscapeControlCharsFull(StringBuilder, string) Method

Append and escape control characters

public static System.Text.StringBuilder AppendEscapeControlCharsFull(this System.Text.StringBuilder str, string s);
Parameters

str System.Text.StringBuilder

s System.String

Returns

System.Text.StringBuilder


Extensions.ApproxEquals(double, double, double) Method

Approximate equal

public static bool ApproxEquals(this double left, double right, double epsilon=2.2204460492503131E-16);
Parameters

left System.Double

right System.Double

epsilon System.Double

Returns

System.Boolean


Extensions.ChangeTo(Type, object) Method

Change value to type

public static object ChangeTo(this System.Type type, object value);
Parameters

type System.Type

value System.Object

Returns

System.Object


Extensions.Checksum(string) Method

Calculate a String parser CheckSumCharBlock value

public static uint Checksum(this string s);
Parameters

s System.String

Returns

System.UInt32


Extensions.EqualsI(string, string) Method

Equals invariant.
Both A and B can be null, if both are null its true. If B is null only, its false as per Equals

public static bool EqualsI(this string a, string b);
Parameters

a System.String
this

b System.String
string

Returns

System.Boolean


Extensions.EscapeControlCharsFull(string) Method

Escape control characters

public static string EscapeControlCharsFull(this string obj);
Parameters

obj System.String

Returns

System.String


Extensions.FieldPropertyType(MemberInfo) Method

Get Type of field property

public static System.Type FieldPropertyType(this System.Reflection.MemberInfo mi);
Parameters

mi System.Reflection.MemberInfo

Returns

System.Type


Extensions.InvariantParseIntNull(string) Method

Parse integer from string invariant culture, return null if not parsed

public static System.Nullable<int> InvariantParseIntNull(this string s);
Parameters

s System.String
string

Returns

System.Nullable<System.Int32>
null of integer


Extensions.RegExWildCardToRegular(string) Method

Change wildcard to Reg Ex Wildcard

public static string RegExWildCardToRegular(this string value);
Parameters

value System.String

Returns

System.String


Extensions.SetValue(MemberInfo, object, object) Method

Set value in member

public static bool SetValue(this System.Reflection.MemberInfo mi, object instance, object value);
Parameters

mi System.Reflection.MemberInfo

instance System.Object

value System.Object

Returns

System.Boolean


Extensions.ToHex(char) Method

Convert character to hex value

public static System.Nullable<int> ToHex(this char c);
Parameters

c System.Char

Returns

System.Nullable<System.Int32>


Extensions.ToStringIntValue(bool) Method

Number helper function - return 1 or 0

public static string ToStringIntValue(this bool v);
Parameters

v System.Boolean

Returns

System.String


Extensions.ToStringInvariant(double) Method

Number helper function

public static string ToStringInvariant(this double v);
Parameters

v System.Double

Returns

System.String


Extensions.ToStringInvariant(double, string) Method

Number helper function

public static string ToStringInvariant(this double v, string format);
Parameters

v System.Double

format System.String

Returns

System.String


Extensions.ToStringInvariant(float) Method

Number helper function

public static string ToStringInvariant(this float v);
Parameters

v System.Single

Returns

System.String


Extensions.ToStringInvariant(float, string) Method

Number helper function

public static string ToStringInvariant(this float v, string format);
Parameters

v System.Single

format System.String

Returns

System.String


Extensions.ToStringInvariant(int) Method

Number helper function

public static string ToStringInvariant(this int v);
Parameters

v System.Int32

Returns

System.String


Extensions.ToStringInvariant(int, string) Method

Number helper function

public static string ToStringInvariant(this int v, string format);
Parameters

v System.Int32

format System.String

Returns

System.String


Extensions.ToStringInvariant(long) Method

Number helper function

public static string ToStringInvariant(this long v);
Parameters

v System.Int64

Returns

System.String


Extensions.ToStringInvariant(long, string) Method

Number helper function

public static string ToStringInvariant(this long v, string format);
Parameters

v System.Int64

format System.String

Returns

System.String


Extensions.ToStringInvariant(Nullable<bool>) Method

Number helper function

public static string ToStringInvariant(this System.Nullable<bool> v);
Parameters

v System.Nullable<System.Boolean>

Returns

System.String


Extensions.ToStringInvariant(Nullable<double>, string) Method

Number helper function

public static string ToStringInvariant(this System.Nullable<double> v, string format);
Parameters

v System.Nullable<System.Double>

format System.String

Returns

System.String


Extensions.ToStringInvariant(Nullable<float>, string) Method

Number helper function

public static string ToStringInvariant(this System.Nullable<float> v, string format);
Parameters

v System.Nullable<System.Single>

format System.String

Returns

System.String


Extensions.ToStringInvariant(Nullable<int>) Method

Number helper function

public static string ToStringInvariant(this System.Nullable<int> v);
Parameters

v System.Nullable<System.Int32>

Returns

System.String


Extensions.ToStringInvariant(Nullable<int>, string) Method

Number helper function

public static string ToStringInvariant(this System.Nullable<int> v, string format);
Parameters

v System.Nullable<System.Int32>

format System.String

Returns

System.String


Extensions.ToStringInvariant(Nullable<long>) Method

Number helper function

public static string ToStringInvariant(this System.Nullable<long> v);
Parameters

v System.Nullable<System.Int64>

Returns

System.String


Extensions.ToStringInvariant(Nullable<long>, string) Method

Number helper function

public static string ToStringInvariant(this System.Nullable<long> v, string format);
Parameters

v System.Nullable<System.Int64>

format System.String

Returns

System.String


Extensions.ToStringInvariant(uint) Method

Number helper function

public static string ToStringInvariant(this uint v);
Parameters

v System.UInt32

Returns

System.String


Extensions.ToStringInvariant(uint, string) Method

Number helper function

public static string ToStringInvariant(this uint v, string format);
Parameters

v System.UInt32

format System.String

Returns

System.String


Extensions.ToStringInvariant(ulong) Method

Number helper function

public static string ToStringInvariant(this ulong v);
Parameters

v System.UInt64

Returns

System.String


Extensions.ToStringInvariant(ulong, string) Method

Number helper function

public static string ToStringInvariant(this ulong v, string format);
Parameters

v System.UInt64

format System.String

Returns

System.String


Extensions.ToStringZulu(DateTime) Method

Date helper function

public static string ToStringZulu(this System.DateTime dt);
Parameters

dt System.DateTime

Returns

System.String


Extensions.WildCardMatch(string, string, bool) Method

Perform wild card Reg Ex

public static bool WildCardMatch(this string value, string match, bool caseinsensitive=false);
Parameters

value System.String

match System.String

caseinsensitive System.Boolean

Returns

System.Boolean

Clone this wiki locally