예제 #1
0
파일: SByte.cs 프로젝트: smartmaster/corert
        public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out SByte result)
        {
            UInt32.ValidateParseStyleInteger(style);
            result = 0;
            int i;

            if (!FormatProvider.TryParseInt32(s, style, provider, out i))
            {
                return(false);
            }

            if ((style & NumberStyles.AllowHexSpecifier) != 0)
            { // We are parsing a hexadecimal number
                if ((i < 0) || i > Byte.MaxValue)
                {
                    return(false);
                }
                result = (sbyte)i;
                return(true);
            }

            if (i < MinValue || i > MaxValue)
            {
                return(false);
            }
            result = (sbyte)i;
            return(true);
        }
예제 #2
0
파일: SByte.cs 프로젝트: smartmaster/corert
        public static sbyte Parse(String s, NumberStyles style, IFormatProvider provider)
        {
            UInt32.ValidateParseStyleInteger(style);
            int i = 0;

            try
            {
                i = FormatProvider.ParseInt32(s, style, provider);
            }
            catch (OverflowException e)
            {
                throw new OverflowException(SR.Overflow_SByte, e);
            }

            if ((style & NumberStyles.AllowHexSpecifier) != 0)
            { // We are parsing a hexadecimal number
                if ((i < 0) || i > Byte.MaxValue)
                {
                    throw new OverflowException(SR.Overflow_SByte);
                }
                return((sbyte)i);
            }

            if (i < MinValue || i > MaxValue)
            {
                throw new OverflowException(SR.Overflow_SByte);
            }
            return((sbyte)i);
        }
예제 #3
0
파일: Int16.cs 프로젝트: smartmaster/corert
        public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Int16 result)
        {
            UInt32.ValidateParseStyleInteger(style);
            result = 0;
            int i;

            if (!FormatProvider.TryParseInt32(s, style, provider, out i))
            {
                return(false);
            }

            // We need this check here since we don't allow signs to specified in hex numbers. So we fixup the result
            // for negative numbers
            if ((style & NumberStyles.AllowHexSpecifier) != 0)
            { // We are parsing a hexadecimal number
                if ((i < 0) || i > UInt16.MaxValue)
                {
                    return(false);
                }
                result = (Int16)i;
                return(true);
            }

            if (i < MinValue || i > MaxValue)
            {
                return(false);
            }
            result = (Int16)i;
            return(true);
        }
예제 #4
0
파일: Int16.cs 프로젝트: smartmaster/corert
        public static short Parse(String s, NumberStyles style, IFormatProvider provider)
        {
            UInt32.ValidateParseStyleInteger(style);
            int i = 0;

            try
            {
                i = FormatProvider.ParseInt32(s, style, provider);
            }
            catch (OverflowException e)
            {
                throw new OverflowException(SR.Overflow_Int16, e);
            }

            // We need this check here since we don't allow signs to specified in hex numbers. So we fixup the result
            // for negative numbers
            if ((style & NumberStyles.AllowHexSpecifier) != 0)
            { // We are parsing a hexadecimal number
                if ((i < 0) || (i > UInt16.MaxValue))
                {
                    throw new OverflowException(SR.Overflow_Int16);
                }
                return((short)i);
            }

            if (i < MinValue || i > MaxValue)
            {
                throw new OverflowException(SR.Overflow_Int16);
            }
            return((short)i);
        }
예제 #5
0
        public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out UInt16 result)
        {
            UInt32.ValidateParseStyleInteger(style);
            result = 0;
            UInt32 i;

            if (!FormatProvider.TryParseUInt32(s, style, provider, out i))
            {
                return(false);
            }
            if (i > MaxValue)
            {
                return(false);
            }
            result = (UInt16)i;
            return(true);
        }
예제 #6
0
파일: Byte.cs 프로젝트: wtgodbe/corert
        public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Byte result)
        {
            UInt32.ValidateParseStyleInteger(style);

            result = 0;
            int i;

            if (!FormatProvider.TryParseInt32(s, style, provider, out i))
            {
                return(false);
            }
            if (i < MinValue || i > MaxValue)
            {
                return(false);
            }
            result = (byte)i;
            return(true);
        }
예제 #7
0
        public static ushort Parse(String s, NumberStyles style, IFormatProvider provider)
        {
            UInt32.ValidateParseStyleInteger(style);
            uint i = 0;

            try
            {
                i = FormatProvider.ParseUInt32(s, style, provider);
            }
            catch (OverflowException e)
            {
                throw new OverflowException(SR.Overflow_UInt16, e);
            }

            if (i > MaxValue)
            {
                throw new OverflowException(SR.Overflow_UInt16);
            }
            return((ushort)i);
        }
예제 #8
0
파일: Byte.cs 프로젝트: wtgodbe/corert
        public static byte Parse(String s, NumberStyles style, IFormatProvider provider)
        {
            UInt32.ValidateParseStyleInteger(style);

            int i = 0;

            try
            {
                i = FormatProvider.ParseInt32(s, style, provider);
            }
            catch (OverflowException e)
            {
                throw new OverflowException(SR.Overflow_Byte, e);
            }

            if (i < MinValue || i > MaxValue)
            {
                throw new OverflowException(SR.Overflow_Byte);
            }
            return((byte)i);
        }
예제 #9
0
파일: Int32.cs 프로젝트: rdlaitila/corert
 public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Int32 result)
 {
     UInt32.ValidateParseStyleInteger(style);
     return(FormatProvider.TryParseInt32(s, style, provider, out result));
 }
예제 #10
0
파일: Int32.cs 프로젝트: rdlaitila/corert
 public static int Parse(String s, NumberStyles style, IFormatProvider provider)
 {
     UInt32.ValidateParseStyleInteger(style);
     return(FormatProvider.ParseInt32(s, style, provider));
 }
예제 #11
0
 public static ushort Parse(String s, NumberStyles style)
 {
     UInt32.ValidateParseStyleInteger(style);
     return(Parse(s, style, null));
 }
예제 #12
0
파일: UInt64.cs 프로젝트: rdlaitila/corert
 public static ulong Parse(String s, NumberStyles style)
 {
     UInt32.ValidateParseStyleInteger(style);
     return(FormatProvider.ParseUInt64(s, style, null));
 }