public static uint CastUInt32(object sourceObj) { switch (sourceObj) { case null: throw new ArgumentException(); case string stringValue: try { return(SimpleTypeParserFunctions.ParseUInt32(stringValue)); } catch (FormatException) { return(default(uint)); } default: return(sourceObj.AsUInt32()); } }
/// <summary> /// Casts the object to the System.UInt32 /// </summary> /// <param name="sourceObj">The source object</param> public static uint?CastNullableUInt32(object sourceObj) { switch (sourceObj) { case null: return(null); case string stringValue: try { return(SimpleTypeParserFunctions.ParseUInt32(stringValue)); } catch (FormatException) { return(default(uint?)); } default: return(sourceObj.AsUInt32()); } }