/// <summary>
 /// The cloneable constructor.
 /// </summary>
 /// <remarks>
 /// This constructor is used for any kind of class cloning.
 /// </remarks>
 /// <param name="order">
 /// The reference of <see cref="IByteOrder"/> to be used to determine
 /// actual byte order.
 /// </param>
 /// <param name="buffer">
 /// The buffer to get all cloneable data from.
 /// </param>
 private BitCharger(IByteOrder order, StringBuilder buffer)
     : base()
 {
     this.helper = order;
     this.buffer = new StringBuilder(buffer.Capacity);
     this.buffer.Append(buffer); // Internally, ToString() is called.
 }
        /// <summary>
        /// The internally visible constructor.
        /// </summary>
        /// <remarks>
        /// Actually, this constructor is only for testing purposes.
        /// </remarks>
        /// <param name="order">
        /// An instance of <see cref="IByteOrder"/> to be used to determine
        /// actual byte order.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The exception is thrown if parameter <paramref name="order"/>
        /// is null.
        /// </exception>
        internal BitCharger(IByteOrder order)
            : base()
        {
            this.helper = order ?? throw new ArgumentNullException(nameof(order));

            this.buffer = new StringBuilder(BitCharger.DefaultCapacity);
        }
示例#3
0
文件: Binary.cs 项目: jinyuttt/NsqCli
        /// <summary>
        /// Read reads structured binary data from <paramref name="r"/>.
        /// Bytes read from <paramref name="r"/> are decoded using the
        /// specified byte <paramref name="order"/> and written to successive
        /// fields of the data.
        /// </summary>
        /// <param name="r">The reader.</param>
        /// <param name="order">The byte order.</param>
        public static int ReadInt32(IReader r, IByteOrder order)
        {
            // NOTE: Departing from "binary.Read", don't want to box/unbox for this low-level call

            var buf = new byte[4];

            r.Read(buf);
            return(order.Int32(buf));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="byteOrder"></param>
        /// <returns></returns>
        public ByteBuffer Order(IByteOrder byteOrder)
        {
            if (byteOrder == null)
            {
                throw new ArgumentNullException("byteOrder");
            }

            order = byteOrder;
            return(this);
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="byteOrder"></param>
        /// <returns></returns>
        public ByteBuffer Order(IByteOrder byteOrder)
        {
            if (byteOrder == null)
            {
                throw new ArgumentNullException("byteOrder");
            }

            order = byteOrder;
            return this;
        }
示例#6
0
        /// <summary>
        /// Read reads structured binary data from <paramref name="r"/>.
        /// Bytes read from <paramref name="r"/> are decoded using the
        /// specified byte <paramref name="order"/> and written to successive
        /// fields of the data.
        /// </summary>
        /// <param name="r">The reader.</param>
        /// <param name="order">The byte order.</param>
        public static int ReadInt32(IReader r, IByteOrder order)
        {
            // NOTE: Departing from "binary.Read", don't want to box/unbox for this low-level call

            var buf = new byte[4];
            r.Read(buf);
            return order.Int32(buf);
        }