Example #1
0
        /// <summary>
        /// Parses integers and real numbers from their binary representation.
        /// <i>Note: real numbers are not yet supported.</i>
        /// </summary>
        /// <param name="bytes">The binary representation</param>
        /// <param name="type">The type of number</param>
        /// <seealso cref="INTEGER"/>
        /// <seealso cref="REAL"/>
        public NSNumber(byte[] bytes, int type)
        {
            switch (type)
            {
            case INTEGER:
                doubleValue = longValue = BinaryPropertyListParser.ParseLong(bytes);
                break;

            case REAL:
                doubleValue = BinaryPropertyListParser.ParseDouble(bytes);
                longValue   = (long)Math.Round(doubleValue);
                break;

            default:
                throw new ArgumentException("Type argument is not valid.");
            }
            this.type = type;
        }