ToUInt32() private method

private ToUInt32 ( DateTime value ) : uint
value DateTime
return uint
Beispiel #1
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);
            Win32API.SetWindowTheme(base.Handle, "explorer", null);
            int lParam = Win32API.SendMessage(base.Handle, Convert.ToUInt32(0x112d), 0, 0) | 0x60;

            Win32API.SendMessage(base.Handle, 0x112c, 0, lParam);
        }
        public uint ToUInt32(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(SConvert.ToUInt32(value, CultureInfo.InvariantCulture));
        }
 public static uint?ToUIntN(this object obj)
 {
     if (obj == null)
     {
         return(null);
     }
     if (obj is bool)
     {
         return(Convert.ToUInt32(obj));
     }
     return(uint.TryParse(obj.ToString().Replace(".", ",").TakeUntil(","), NumberStyles.Any, Culture, out uint tmpvalue) ? tmpvalue : (uint?)null);
 }
 private static void RegisterDecimalConversions(
     ITypeConverterRegistry registry)
 {
     registry.Register <decimal, short>(from => SysConv.ToInt16(from));
     registry.Register <decimal, int>(from => SysConv.ToInt32(from));
     registry.Register <decimal, long>(from => SysConv.ToInt64(from));
     registry.Register <decimal, ushort>(from => SysConv.ToUInt16(from));
     registry.Register <decimal, uint>(from => SysConv.ToUInt32(from));
     registry.Register <decimal, ulong>(from => SysConv.ToUInt64(from));
     registry.Register <decimal, float>(from => SysConv.ToSingle(from));
     registry.Register <decimal, double>(from => SysConv.ToDouble(from));
     registry.Register <decimal, string>(from =>
                                         from.ToString("E", CultureInfo.InvariantCulture));
 }
 private static void RegisterDoubleConversions(
     ITypeConverterRegistry registry)
 {
     registry.Register <double, byte>(from => SysConv.ToByte(from));
     registry.Register <double, short>(from => SysConv.ToInt16(from));
     registry.Register <double, int>(from => SysConv.ToInt32(from));
     registry.Register <double, long>(from => SysConv.ToInt64(from));
     registry.Register <double, ushort>(from => SysConv.ToUInt16(from));
     registry.Register <double, uint>(from => SysConv.ToUInt32(from));
     registry.Register <double, ulong>(from => SysConv.ToUInt64(from));
     registry.Register <double, decimal>(from => SysConv.ToDecimal(from));
     registry.Register <double, float>(from => SysConv.ToSingle(from));
     registry.Register <double, string>(from =>
                                        from.ToString(CultureInfo.InvariantCulture));
 }
Beispiel #6
0
 private static void RegisterSingleConversions(
     DefaultTypeConverter registry)
 {
     registry.Register <float, byte>(from => SysConv.ToByte(from));
     registry.Register <float, short>(from => SysConv.ToInt16(from));
     registry.Register <float, int>(from => SysConv.ToInt32(from));
     registry.Register <float, long>(from => SysConv.ToInt64(from));
     registry.Register <float, ushort>(from => SysConv.ToUInt16(from));
     registry.Register <float, uint>(from => SysConv.ToUInt32(from));
     registry.Register <float, ulong>(from => SysConv.ToUInt64(from));
     registry.Register <float, decimal>(from => SysConv.ToDecimal(from));
     registry.Register <float, double>(from => SysConv.ToDouble(from));
     registry.Register <float, string>(from =>
                                       from.ToString(CultureInfo.InvariantCulture));
 }
        protected static internal object ConvertValue(Type type, NSJSValue value)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            object o = FetchValue(type, value);

            if (type == typeof(int))
            {
                o = (o == null ? 0 : Converter.ToInt32(o));
            }
            else if (type == typeof(uint))
            {
                o = (o == null ? 0u : Converter.ToUInt32(o));
            }
            else if (type == typeof(short))
            {
                o = (o == null ? (short)0 : Converter.ToInt16(o));
            }
            else if (type == typeof(ushort))
            {
                o = (o == null ? (ushort)0 : Converter.ToUInt16(o));
            }
            else if (type == typeof(sbyte))
            {
                o = (o == null ? (sbyte)0 : Converter.ToSByte(o));
            }
            else if (type == typeof(byte))
            {
                o = (o == null ? (byte)0 : Converter.ToByte(o));
            }
            else if (type == typeof(long))
            {
                o = (o == null ? 0L : Converter.ToInt64(o));
            }
            else if (type == typeof(ulong))
            {
                o = (o == null ? 0ul : Converter.ToUInt64(o));
            }
            else if (type == typeof(float))
            {
                o = (o == null ? 0f : Converter.ToSingle(o));
            }
            else if (type == typeof(double))
            {
                o = (o == null ? 0d : Converter.ToDouble(o));
            }
            else if (type == typeof(decimal))
            {
                o = (o == null ? 0m : Converter.ToDecimal(o));
            }
            else if (type == typeof(char))
            {
                o = (o == null ? '\0' : Converter.ToChar(o));
            }
            else if (type == typeof(DateTime))
            {
                long ticks = 0;
                if (o is long)
                {
                    ticks = (long)o;
                }
                else if (o != null)
                {
                    ticks = Converter.ToInt64(o);
                }
                o = NSJSDateTime.LocalDateToDateTime(ticks);
            }
            else if (type == typeof(string))
            {
                if (o == null)
                {
                    o = null;
                }
                else if (!(o is string))
                {
                    o = o.ToString();
                }
            }
            else if (typeof(NSJSValue).IsAssignableFrom(type))
            {
                return(type.IsInstanceOfType(value) ? value : null);
            }
            return(o);
        }
Beispiel #8
0
 public uint ToUInt32(object value)
     => SystemConvert.ToUInt32(value);
Beispiel #9
0
 /// <internalonly/>
 uint IConvertible.ToUInt32(IFormatProvider provider)
 {
     return(Convert.ToUInt32(m_value));
 }
Beispiel #10
0
		uint IConvertible.ToUInt32 (IFormatProvider provider)
		{
			return Convert.ToUInt32 (Value, provider);
		}
Beispiel #11
0
 uint IConvertible.ToUInt32(IFormatProvider provider)
 {
     return(Convert.ToUInt32((float)this));
 }