/// <summary>
 /// Encode DomainMCSPDU to a byte list.
 /// </summary>
 /// <param name="buffer">The buffer list to contain the PDU.
 /// This argument cannot be null. It may throw ArgumentNullException if it is null.</param>
 /// <param name="domainMcsPdu">The PDU to be encoded.
 /// This argument can be null. If it is null, the method will encode nothing.</param>
 internal static void EncodeDomainMcsPdu(List <byte> buffer, DomainMCSPDU domainMcsPdu)
 {
     if (domainMcsPdu != null)
     {
         Asn1PerEncodingBuffer perEncodeBuffer = new Asn1PerEncodingBuffer(true);
         domainMcsPdu.PerEncode(perEncodeBuffer);
         buffer.AddRange(perEncodeBuffer.ByteArrayData);
     }
 }
        internal static void EncodeSlowPathPdu(List <byte> sendBuffer,
                                               SlowPathPduCommonHeader commonHeader,
                                               byte[] dataBody,
                                               RdpbcgrServerSessionContext context)
        {
            EncodeStructure(sendBuffer, commonHeader.tpktHeader);
            EncodeStructure(sendBuffer, commonHeader.x224Data);

            List <byte> securityBuffer = new List <byte>();

            EncodeSecurityData(securityBuffer, commonHeader.securityHeader, dataBody, context);

            SendDataIndication securityExchange = new SendDataIndication(new UserId(commonHeader.initiator),
                                                                         new ChannelId(commonHeader.channelId),
                                                                         new DataPriority(ConstValue.SEND_DATA_REQUEST_PRIORITY),
                                                                         ConstValue.SEND_DATA_REQUEST_SEGMENTATION,
                                                                         new Asn1OctetString(securityBuffer.ToArray()));
            DomainMCSPDU mcsDomain = new DomainMCSPDU(DomainMCSPDU.sendDataIndication, securityExchange);

            EncodeDomainMcsPdu(sendBuffer, mcsDomain);
        }