/// <summary> /// Casts the object to the System.Numerics.BigInteger /// </summary> /// <param name="sourceObj">The source object</param> public static BigInteger?CastNullableBigInteger(object sourceObj) { switch (sourceObj) { case null: return(null); case string stringValue: try { return(SimpleTypeParserFunctions.ParseBigInteger(stringValue)); } catch (FormatException) { return(default(BigInteger?)); } default: return(sourceObj.AsBigInteger()); } }
/// <summary> /// Casts the object to the System.Decimal /// </summary> /// <param name="sourceObj">The source object</param> public static decimal?CastNullableDecimal(object sourceObj) { switch (sourceObj) { case null: return(null); case string stringValue: try { return(SimpleTypeParserFunctions.ParseDecimal(stringValue)); } catch (FormatException) { return(default(decimal?)); } default: return(sourceObj.AsDecimal()); } }
public static decimal CastDecimal(object sourceObj) { switch (sourceObj) { case null: throw new ArgumentException(); case string stringValue: try { return(SimpleTypeParserFunctions.ParseDecimal(stringValue)); } catch (FormatException) { return(default(decimal)); } default: return(sourceObj.AsDecimal()); } }
/// <summary> /// Casts the object to the System.Single /// </summary> /// <param name="sourceObj">The source object</param> public static float?CastNullableSingle(object sourceObj) { switch (sourceObj) { case null: return(null); case string stringValue: try { return(SimpleTypeParserFunctions.ParseFloat(stringValue)); } catch (FormatException) { return(default(float?)); } default: return(sourceObj.AsFloat()); } }
public static float CastSingle(object sourceObj) { switch (sourceObj) { case null: throw new ArgumentException(); case string stringValue: try { return(SimpleTypeParserFunctions.ParseFloat(stringValue)); } catch (FormatException) { return(default(float)); } default: return(sourceObj.AsFloat()); } }
public static ulong CastUInt64(object sourceObj) { switch (sourceObj) { case null: throw new ArgumentException(); case string stringValue: try { return(SimpleTypeParserFunctions.ParseUInt64(stringValue)); } catch (FormatException) { return(default(ulong)); } default: return(sourceObj.AsUInt64()); } }
/// <summary> /// Casts the object to the System.UInt64 /// </summary> /// <param name="sourceObj">The source object</param> public static ulong?CastNullableUInt64(object sourceObj) { switch (sourceObj) { case null: return(null); case string stringValue: try { return(SimpleTypeParserFunctions.ParseUInt64(stringValue)); } catch (FormatException) { return(default(ulong?)); } default: return(sourceObj.AsUInt64()); } }
public static int CastInt32(object sourceObj) { switch (sourceObj) { case null: throw new ArgumentException(); case string stringValue: try { return(SimpleTypeParserFunctions.ParseInt32(stringValue)); } catch (FormatException) { return(default(int)); } default: return(sourceObj.AsInt32()); } }
/// <summary> /// Casts the object to the System.Int32 /// </summary> /// <param name="sourceObj">The source object</param> public static int?CastNullableInt32(object sourceObj) { switch (sourceObj) { case null: return(null); case string stringValue: try { return(SimpleTypeParserFunctions.ParseInt32(stringValue)); } catch (FormatException) { return(default(int?)); } default: return(sourceObj.AsInt32()); } }
public static byte CastByte(object sourceObj) { switch (sourceObj) { case null: throw new ArgumentException(); case string stringValue: try { return(SimpleTypeParserFunctions.ParseByte(stringValue)); } catch (FormatException) { return(default(byte)); } default: return(sourceObj.AsByte()); } }