internal HeaderWriteState(ElementTypeDescriptor elementTypeDescriptor, byte[] buf, int offset, SizeIndex sizeIndex, int headerLength)
 {
     this.Etd          = elementTypeDescriptor;
     this.HeaderOffset = offset;
     this.SizeIndex    = sizeIndex;
     this.HeaderLength = headerLength;
     //
     VerifyWriteSpaceRemaining(HeaderLength, buf, offset);
     ServiceRecordParser.VerifyAllowedSizeIndex(Etd, SizeIndex, false);
 }
        private int WriteHeaderFixedLength_(ElementTypeDescriptor elementTypeDescriptor, int contentLength, SizeIndex sizeIndex,
                                            byte[] buf, int offset,
                                            out int totalLength)
        {
            System.Diagnostics.Debug.Assert(
                sizeIndex == SizeIndex.LengthOneByteOrNil ||
                sizeIndex == SizeIndex.LengthTwoBytes ||
                sizeIndex == SizeIndex.LengthFourBytes ||
                sizeIndex == SizeIndex.LengthEightBytes ||
                sizeIndex == SizeIndex.LengthSixteenBytes);
            ServiceRecordParser.VerifyAllowedSizeIndex(elementTypeDescriptor, sizeIndex, false);
            HeaderWriteState headerState = new HeaderWriteState(elementTypeDescriptor, buf, offset, sizeIndex, 1);

            CompleteHeaderWrite(headerState, buf, offset + contentLength + headerState.HeaderLength, out totalLength);
            return(headerState.HeaderLength);
        }