Class ObjectValueConversion
Provides extension methods for converting object values to different scalar types
Inheritance
System.Object
ObjectValueConversion
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Azos.dll
Syntax
public static class ObjectValueConversion
Fields
RADIX_BIN
Declaration
public const string RADIX_BIN = "0b"
Field Value
Type |
Description |
System.String |
|
RADIX_HEX
Declaration
public const string RADIX_HEX = "0x"
Field Value
Type |
Description |
System.String |
|
Methods
AsBool(Object, Boolean, ConvertErrorHandling)
Declaration
public static bool AsBool(this object val, bool dflt = false, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Boolean |
|
AsByte(Object, Byte, ConvertErrorHandling)
Declaration
public static byte AsByte(this object val, byte dflt = 0, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Byte |
|
AsChar(Object, Char, ConvertErrorHandling)
Declaration
public static char AsChar(this object val, char dflt = '\0', ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Char |
|
AsDateTime(Object)
Declaration
public static DateTime AsDateTime(this object val)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
Returns
Type |
Description |
System.DateTime |
|
AsDateTime(Object, DateTime, ConvertErrorHandling)
Declaration
public static DateTime AsDateTime(this object val, DateTime dflt, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.DateTime |
|
AsDecimal(Object, Decimal, ConvertErrorHandling)
Declaration
public static decimal AsDecimal(this object val, decimal dflt = 0M, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Decimal |
|
AsDouble(Object, Double, ConvertErrorHandling)
Declaration
public static double AsDouble(this object val, double dflt = 0, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Double |
|
AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
Declaration
public static TEnum AsEnum<TEnum>(this object val, TEnum dflt, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
where TEnum : struct
Parameters
Returns
Type Parameters
AsFloat(Object, Single, ConvertErrorHandling)
Declaration
public static float AsFloat(this object val, float dflt = 0F, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Single |
|
AsGDID(Object)
Declaration
public static GDID AsGDID(this object val)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
Returns
AsGDID(Object, GDID, ConvertErrorHandling)
Declaration
public static GDID AsGDID(this object val, GDID dflt, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
AsGDIDSymbol(Object)
Declaration
public static GDIDSymbol AsGDIDSymbol(this object val)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
Returns
AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
Declaration
public static GDIDSymbol AsGDIDSymbol(this object val, GDIDSymbol dflt, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
AsGUID(Object, Guid, ConvertErrorHandling)
Declaration
public static Guid AsGUID(this object val, Guid dflt, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Guid |
|
AsInt(Object, Int32, ConvertErrorHandling)
Declaration
public static int AsInt(this object val, int dflt = 0, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Int32 |
|
AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
Declaration
public static ConfigSectionNode AsJSONConfig(this object val, ConfigSectionNode dflt = null, string wrapRootName = "azos", ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
Declaration
public static ConfigSectionNode AsLaconicConfig(this object val, ConfigSectionNode dflt = null, string wrapRootName = "azos", ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
AsLong(Object, Int64, ConvertErrorHandling)
Declaration
public static long AsLong(this object val, long dflt = 0L, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Int64 |
|
AsNonNullOrEmptyString(Object)
Declaration
public static string AsNonNullOrEmptyString(this object val)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
Returns
Type |
Description |
System.String |
|
AsNullableBool(ObjectValueConversion.TriStateBool)
Declaration
public static bool? AsNullableBool(this ObjectValueConversion.TriStateBool val)
Parameters
Returns
Type |
Description |
System.Nullable<System.Boolean> |
|
AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
Declaration
public static bool? AsNullableBool(this object val, bool? dflt = default(bool? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Boolean> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Boolean> |
|
AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
Declaration
public static byte? AsNullableByte(this object val, byte? dflt = default(byte? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Byte> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Byte> |
|
AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
Declaration
public static char? AsNullableChar(this object val, char? dflt = default(char? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Char> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Char> |
|
AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
Declaration
public static DateTime? AsNullableDateTime(this object val, DateTime? dflt = default(DateTime? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.DateTime> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.DateTime> |
|
AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
Declaration
public static decimal? AsNullableDecimal(this object val, decimal? dflt = default(decimal? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Decimal> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Decimal> |
|
AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
Declaration
public static double? AsNullableDouble(this object val, double? dflt = default(double? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Double> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Double> |
|
AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
Declaration
public static TEnum? AsNullableEnum<TEnum>(this object val, TEnum? dflt = default(TEnum? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
where TEnum : struct
Parameters
Returns
Type |
Description |
System.Nullable<TEnum> |
|
Type Parameters
AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
Declaration
public static float? AsNullableFloat(this object val, float? dflt = default(float? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Single> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Single> |
|
AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
Declaration
public static GDID? AsNullableGDID(this object val, GDID? dflt = default(GDID? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Nullable<GDID> |
|
AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
Declaration
public static GDIDSymbol? AsNullableGDIDSymbol(this object val, GDIDSymbol? dflt = default(GDIDSymbol? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
Declaration
public static Guid? AsNullableGUID(this object val, Guid? dflt = default(Guid? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Guid> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Guid> |
|
AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
Declaration
public static int? AsNullableInt(this object val, int? dflt = default(int? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Int32> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Int32> |
|
AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
Declaration
public static long? AsNullableLong(this object val, long? dflt = default(long? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Int64> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Int64> |
|
AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
Declaration
public static sbyte? AsNullableSByte(this object val, sbyte? dflt = default(sbyte? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.SByte> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.SByte> |
|
AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
Declaration
public static short? AsNullableShort(this object val, short? dflt = default(short? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.Int16> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.Int16> |
|
AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
Declaration
public static TimeSpan? AsNullableTimeSpan(this object val, TimeSpan? dflt = default(TimeSpan? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.TimeSpan> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.TimeSpan> |
|
AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
Declaration
public static uint? AsNullableUInt(this object val, uint? dflt = default(uint? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.UInt32> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.UInt32> |
|
AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
Declaration
public static ulong? AsNullableULong(this object val, ulong? dflt = default(ulong? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.UInt64> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.UInt64> |
|
AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
Declaration
public static ushort? AsNullableUShort(this object val, ushort? dflt = default(ushort? ), ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
System.Nullable<System.UInt16> |
dflt |
|
ConvertErrorHandling |
handling |
|
Returns
Type |
Description |
System.Nullable<System.UInt16> |
|
AsSByte(Object, SByte, ConvertErrorHandling)
Declaration
public static sbyte AsSByte(this object val, sbyte dflt = 0, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.SByte |
|
AsShort(Object, Int16, ConvertErrorHandling)
Declaration
public static short AsShort(this object val, short dflt = 0, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Int16 |
|
AsString(Object, String, ConvertErrorHandling)
Declaration
public static string AsString(this object val, string dflt = null, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.String |
|
AsTimeSpan(Object)
Declaration
public static TimeSpan AsTimeSpan(this object val)
Parameters
Type |
Name |
Description |
System.Object |
val |
|
Returns
Type |
Description |
System.TimeSpan |
|
AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
Declaration
public static TimeSpan AsTimeSpan(this object val, TimeSpan dflt, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.TimeSpan |
|
AsUInt(Object, UInt32, ConvertErrorHandling)
Declaration
public static uint AsUInt(this object val, uint dflt = 0U, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.UInt32 |
|
AsULong(Object, UInt64, ConvertErrorHandling)
Declaration
public static ulong AsULong(this object val, ulong dflt = 0UL, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.UInt64 |
|
AsUri(Object, Uri, ConvertErrorHandling)
Declaration
public static Uri AsUri(this object val, Uri dflt = null, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.Uri |
|
AsUShort(Object, UInt16, ConvertErrorHandling)
Declaration
public static ushort AsUShort(this object val, ushort dflt = 0, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns
Type |
Description |
System.UInt16 |
|
AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
Declaration
public static ConfigSectionNode AsXMLConfig(this object val, ConfigSectionNode dflt = null, ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault)
Parameters
Returns