ReadUInt64() public static method

Read a ulong value from a stream and advances the position within the stream by 8.
public static ReadUInt64 ( Stream stream ) : ulong
stream Stream The stream.
return ulong
Ejemplo n.º 1
0
        /// <summary>
        /// Deserialize fields in this class from a stream.
        /// </summary>
        /// <param name="stream">Stream contains a serialized instance of this class.</param>
        /// <param name="size">The number of bytes can read if -1, no limitation.</param>
        /// <returns>Bytes have been read from the stream.</returns>
        public override int Deserialize(Stream stream, int size)
        {
            int bytesRead = 0;

            this.version = StreamHelper.ReadUInt16(stream);
            bytesRead   += 2;
            if (size >= 0 && bytesRead > size)
            {
                AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead);
            }

            this.padding1 = StreamHelper.ReadUInt16(stream);
            bytesRead    += 2;
            if (size >= 0 && bytesRead > size)
            {
                AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead);
            }

            this.faiMessageCount = StreamHelper.ReadUInt32(stream);
            bytesRead           += 4;
            if (size >= 0 && bytesRead > size)
            {
                AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead);
            }

            this.faiMessageTotalSize = StreamHelper.ReadUInt64(stream);
            bytesRead += 8;
            if (size >= 0 && bytesRead > size)
            {
                AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead);
            }

            this.normalMessageCount = StreamHelper.ReadUInt32(stream);
            bytesRead += 4;
            if (size >= 0 && bytesRead > size)
            {
                AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead);
            }

            this.padding2 = StreamHelper.ReadUInt32(stream);
            bytesRead    += 4;
            if (size >= 0 && bytesRead > size)
            {
                AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead);
            }

            this.normalMessageTotalSize = StreamHelper.ReadUInt64(stream);
            bytesRead += 8;
            if (size >= 0 && bytesRead > size)
            {
                AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead);
            }

            return(bytesRead);
        }