ToUInt32() private method

private ToUInt32 ( string s ) : UInt32
s string
return System.UInt32
Example #1
0
        internal static object StringToObject(Type type, string value)
        {
            if (value == null || value == String.Empty)
            {
                return(DBNull.Value);
            }

            switch (Type.GetTypeCode(type))
            {
            case TypeCode.Boolean: return(XmlConvert.ToBoolean(value));

            case TypeCode.Byte: return(XmlConvert.ToByte(value));

            case TypeCode.Char: return((char)XmlConvert.ToInt32(value));

#if NET_2_0
            case TypeCode.DateTime: return(XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Unspecified));
#else
            case TypeCode.DateTime: return(XmlConvert.ToDateTime(value));
#endif
            case TypeCode.Decimal: return(XmlConvert.ToDecimal(value));

            case TypeCode.Double: return(XmlConvert.ToDouble(value));

            case TypeCode.Int16: return(XmlConvert.ToInt16(value));

            case TypeCode.Int32: return(XmlConvert.ToInt32(value));

            case TypeCode.Int64: return(XmlConvert.ToInt64(value));

            case TypeCode.SByte: return(XmlConvert.ToSByte(value));

            case TypeCode.Single: return(XmlConvert.ToSingle(value));

            case TypeCode.UInt16: return(XmlConvert.ToUInt16(value));

            case TypeCode.UInt32: return(XmlConvert.ToUInt32(value));

            case TypeCode.UInt64: return(XmlConvert.ToUInt64(value));
            }

            if (type == typeof(TimeSpan))
            {
                return(XmlConvert.ToTimeSpan(value));
            }
            if (type == typeof(Guid))
            {
                return(XmlConvert.ToGuid(value));
            }
            if (type == typeof(byte[]))
            {
                return(Convert.FromBase64String(value));
            }

            return(Convert.ChangeType(value, type));
        }
Example #2
0
 public static UInt32 StringToUnsignedInt(string value)
 {
     return(XmlConvert.ToUInt32(value));
 }
Example #3
0
 public static long StringToUnsignedInt(string value)
 {
     return((long)((ulong)XmlConvert.ToUInt32(value)));
 }
Example #4
0
        public static uint?GetAttributeUInt([NotNull] this XmlReader reader, string name, uint?Default = null)
        {
            var str = reader.GetAttribute(name);

            return(str is null ? Default : XmlConvert.ToUInt32(str));
        }