Class Utils
Utilities methods for converting values from and to the command API
Inheritance
Namespace: BiExcellence.OpenBi.Api.Internal
Assembly: BiExcellence.OpenBi.Api.dll
Syntax
public static class Utils
Methods
BooleanToString(bool)
Converts a bool to a string.
Example:
true
=> "X"
false
=> ""
Declaration
public static string BooleanToString(bool boolean)
Parameters
Type | Name | Description |
---|---|---|
bool | boolean | The boolean value. |
Returns
Type | Description |
---|---|
string | The converted string. |
DateTimeOffsetToString(DateTimeOffset)
Converts a DateTimeOffset to a string.
Declaration
public static string DateTimeOffsetToString(DateTimeOffset dateTimeOffset)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dateTimeOffset | The date value. |
Returns
Type | Description |
---|---|
string | The converted string. |
FireEvent<T>(object, string, T)
Fires the event of the target object with args.
Declaration
public static void FireEvent<T>(this object target, string eventName, T args) where T : EventArgs
Parameters
Type | Name | Description |
---|---|---|
object | target | The object which declared the event (also the sender). |
string | eventName | The event name. |
T | args | The event args. |
Type Parameters
Name | Description |
---|---|
T | The event args type. |
FireEvent<T>(object, string, object, T)
Fires the event of the target object with args.
Declaration
public static void FireEvent<T>(this object target, string eventName, object sender, T args) where T : EventArgs
Parameters
Type | Name | Description |
---|---|---|
object | target | The object which declared the event. |
string | eventName | The event name. |
object | sender | The sender object for the event. |
T | args | The event args. |
Type Parameters
Name | Description |
---|---|
T | The event args type |
GetCustomAttributeIncludingBaseInterfaces<T>(Type)
Returns the first attribute also from interface for the generic type.
Declaration
public static T? GetCustomAttributeIncludingBaseInterfaces<T>(this Type type) where T : Attribute
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The attribute type. |
GetCustomAttributesIncludingBaseInterfaces<T>(Type)
Returns all attributes also from interfaces for the generic type.
Declaration
public static IEnumerable<T> GetCustomAttributesIncludingBaseInterfaces<T>(this Type type) where T : Attribute
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
IEnumerable<T> |
Type Parameters
Name | Description |
---|---|
T | The attribute type. |
GetOrAddSerializable<T>(IOpenBiRequest, Func<T>)
Returns an existing serializeable or creates a new one.
Declaration
public static T GetOrAddSerializable<T>(this IOpenBiRequest openBiRequest, Func<T> createSerializer) where T : IOpenBiRequestSerializable
Parameters
Type | Name | Description |
---|---|---|
IOpenBiRequest | openBiRequest | The request. |
Func<T> | createSerializer | The func to create a new serializable if there isn't an existing one. |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The serializeable type. |
StringToBoolean(string?)
Declaration
public static bool StringToBoolean(string? str)
Parameters
Type | Name | Description |
---|---|---|
string | str | The string value. |
Returns
Type | Description |
---|---|
bool |
|
StringToDateTimeOffset(string?)
Converts a string to a DateTimeOffset.
Declaration
public static DateTimeOffset? StringToDateTimeOffset(string? str)
Parameters
Type | Name | Description |
---|---|---|
string | str | The string. |
Returns
Type | Description |
---|---|
DateTimeOffset? | The converted DateTimeOffset or |
ToArray(JsonElement)
Tries to find a JsonElement inside of the JsonElement.
Examples:
1
=> [1]
[1,2,3]
=> [1,2,3]
{"list":[1,2,3]}
=> [1,2,3]
Declaration
public static IEnumerable<JsonElement> ToArray(this JsonElement element)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
IEnumerable<JsonElement> | An enumerable over the array. |
ToBoolean(JsonElement)
Converts a JsonElement to a bool. Examples: true => true "X" => true (other) => false
Declaration
public static bool? ToBoolean(this JsonElement element)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
bool? | The converted bool or |
ToByteArray(JsonElement)
Converts a JsonElement to a byte array.
Examples:
"(base 64)"
=> byte[]
(other) => null
Declaration
public static byte[]? ToByteArray(this JsonElement element)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
byte[] | The converted byte array or |
ToDateTimeOffset(JsonElement)
Converts a JsonElement to a DateTimeOffset.
Declaration
public static DateTimeOffset? ToDateTimeOffset(this JsonElement element)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
DateTimeOffset? | The converted DateTimeOffset or |
ToDouble(JsonElement)
Converts a JsonElement to a double.
Declaration
public static double? ToDouble(this JsonElement element)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
double? | The Converted double or |
ToEnum<TEnum>(JsonElement)
Converts a JsonElement to an enum.
Declaration
public static TEnum ToEnum<TEnum>(this JsonElement element) where TEnum : struct
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
TEnum | The converted enum value or the default enum value for the enum type. |
Type Parameters
Name | Description |
---|---|
TEnum | The enum type. |
ToInteger(JsonElement)
Converts a JsonElement to a int.
Declaration
public static int? ToInteger(this JsonElement element)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
int? | The converted int or |
ToLong(JsonElement)
Converts a JsonElement to a long.
Declaration
public static long? ToLong(this JsonElement element)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
long? | The converted long or |
ToObject(JsonElement)
Converts a JsonElement to a .NET object.
Declaration
public static object? ToObject(this JsonElement element)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | element | The json element. |
Returns
Type | Description |
---|---|
object | The converted .NET object or the raw json text. |