Пример #1
0
        /// <summary>
        ///    Constructs and initializes a new instance of <see
        ///    cref="BeginRequestBody" /> by reading the body of a
        ///    specified record.
        /// </summary>
        /// <param name="record">
        ///    A <see cref="Record" /> object containing the body to
        ///    read.
        /// </param>
        /// <exception cref="ArgumentException">
        ///    <paramref name="record" /> is not of type <see
        ///    cref="RecordType.BeginRequest" /> or does not contain
        ///    exactly 8 bytes of body data.
        /// </exception>
        public BeginRequestBody(Record record)
        {
            if (record.Type != RecordType.BeginRequest)
            {
                throw new ArgumentException(
                          Strings.BeginRequestBody_WrongType,
                          "record");
            }

            if (record.BodyLength != 8)
            {
                throw new ArgumentException(
                          Strings.BeginRequestBody_WrongSize, "record");
            }

            byte[] body = record.GetBody();
            role  = (Role)Record.ReadUInt16(body, 0);
            flags = (BeginRequestFlags)body [2];
        }
Пример #2
0
        public BeginRequestBody(Record record)
        {
            if (record.Type != RecordType.BeginRequest)
            {
                throw new ArgumentException(
                          Strings.BeginRequestBody_WrongType,
                          "record");
            }

            if (record.BodyLength != 8)
            {
                throw new ArgumentException(
                          String.Format(Strings.BeginRequestBody_WrongSize, record.BodyLength), "record");
            }

            IReadOnlyList <byte> body;

            record.GetBody(out body);
            role  = (Role)Record.ReadUInt16(body, 0);
            flags = (BeginRequestFlags)body [2];
        }