public static long CastInt64(object sourceObj) { switch (sourceObj) { case null: throw new ArgumentException(); case string stringValue: try { return(SimpleTypeParserFunctions.ParseInt64(stringValue)); } catch (FormatException) { return(default(long)); } default: return(sourceObj.AsInt64()); } }
/// <summary> /// Casts the object to the System.Int64 /// </summary> /// <param name="sourceObj">The source object</param> public static long?CastNullableInt64(object sourceObj) { switch (sourceObj) { case null: return(null); case string stringValue: try { return(SimpleTypeParserFunctions.ParseInt64(stringValue)); } catch (FormatException) { return(default(long?)); } default: return(sourceObj.AsInt64()); } }