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;
        }
Example #2
0
 /// <summary>
 /// Creates a date from its binary representation.
 /// </summary>
 /// <param name="bytes">bytes The date bytes</param>
 public NSDate(byte[] bytes)
 {
     //dates are 8 byte big-endian double, seconds since the epoch
     date = EPOCH.AddSeconds(BinaryPropertyListParser.ParseDouble(bytes));
 }