Class Extensions
- Namespace
- Albatross.Expression
- Assembly
- Albatross.Expression.dll
Provides extension methods for type conversion and object manipulation within the Expression framework.
public static class Extensions
- Inheritance
-
Extensions
- Inherited Members
Methods
ConvertToBoolean(object)
Converts an object to a boolean value with support for various input types.
public static bool ConvertToBoolean(this object obj)
Parameters
objobjectThe object to convert to boolean.
Returns
- bool
The boolean representation of the object.
Exceptions
- FormatException
Thrown when the object cannot be converted to boolean.
ConvertToDateTime(object)
Converts an object to a DateTime value with support for various date types.
public static DateTime ConvertToDateTime(this object obj)
Parameters
objobjectThe object to convert to DateTime.
Returns
- DateTime
The DateTime representation of the object.
Exceptions
- FormatException
Thrown when the object cannot be converted to DateTime.
ConvertToDouble(object)
Converts an object to a double value with support for various numeric types.
public static double ConvertToDouble(this object obj)
Parameters
objobjectThe object to convert to double.
Returns
- double
The double representation of the object.
Exceptions
- FormatException
Thrown when the object cannot be converted to double.
ConvertToInt(object)
Converts an object to an integer value with rounding for double values.
public static int ConvertToInt(this object obj)
Parameters
objobjectThe object to convert to int.
Returns
- int
The integer representation of the object.
Exceptions
- FormatException
Thrown when the object cannot be converted to int.
ConvertToJsonElement(object)
Converts an object to a JsonElement by parsing string content or returning existing JsonElement.
public static JsonElement ConvertToJsonElement(this object obj)
Parameters
objobjectThe object to convert to JsonElement.
Returns
- JsonElement
A JsonElement representation of the object.
Exceptions
- FormatException
Thrown when the object cannot be converted to JsonElement.
ConvertToString(object)
Converts an object to its string representation, handling JsonElement and other types.
public static string ConvertToString(this object obj)
Parameters
objobjectThe object to convert to string.
Returns
- string
A string representation of the object, or an empty string if the object is null.
GetJsonValue(JsonElement)
Extracts the underlying value from a JsonElement into appropriate .NET types.
public static object? GetJsonValue(this JsonElement elem)
Parameters
elemJsonElementThe JsonElement to extract value from.
Returns
- object
The underlying value as a .NET object, or null for null/undefined JSON values.