Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.Server_Save_Session_Info_Pdu.EncodeLogonExtended C# (CSharp) Method

EncodeLogonExtended() private method

private EncodeLogonExtended ( TS_LOGON_INFO_EXTENDED logonInfo ) : byte[]
logonInfo TS_LOGON_INFO_EXTENDED
return byte[]
        private byte[] EncodeLogonExtended(TS_LOGON_INFO_EXTENDED logonInfo)
        {
            List<byte> dataBuffer = new List<byte>();
            RdpbcgrEncoder.EncodeStructure(dataBuffer, logonInfo.Length);
            RdpbcgrEncoder.EncodeStructure(dataBuffer, (uint)logonInfo.FieldsPresent);
            for (int i = 0; i < logonInfo.LogonFields.Length; ++i)
            {
                if (logonInfo.LogonFields[i].FieldData.GetType() == typeof(TS_LOGON_ERRORS_INFO))
                {
                    RdpbcgrEncoder.EncodeStructure(dataBuffer, logonInfo.LogonFields[i].cbFieldData);
                    RdpbcgrEncoder.EncodeStructure(dataBuffer,
                        (uint)((TS_LOGON_ERRORS_INFO)logonInfo.LogonFields[i].FieldData).ErrorNotificationType);
                    RdpbcgrEncoder.EncodeStructure(dataBuffer,
                        ((TS_LOGON_ERRORS_INFO)logonInfo.LogonFields[i].FieldData).ErrorNotificationData);
                }
                else if (logonInfo.LogonFields[i].FieldData.GetType() == typeof(ARC_SC_PRIVATE_PACKET))
                {
                    RdpbcgrEncoder.EncodeStructure(dataBuffer, logonInfo.LogonFields[i].cbFieldData);
                    RdpbcgrEncoder.EncodeStructure(dataBuffer,
                        (uint)((ARC_SC_PRIVATE_PACKET)logonInfo.LogonFields[i].FieldData).cbLen);
                    RdpbcgrEncoder.EncodeStructure(dataBuffer,
                        (uint)((ARC_SC_PRIVATE_PACKET)logonInfo.LogonFields[i].FieldData).Version);
                    RdpbcgrEncoder.EncodeStructure(dataBuffer,
                        ((ARC_SC_PRIVATE_PACKET)logonInfo.LogonFields[i].FieldData).LogonId);
                    RdpbcgrEncoder.EncodeBytes(dataBuffer,
                        ((ARC_SC_PRIVATE_PACKET)logonInfo.LogonFields[i].FieldData).ArcRandomBits);
                }
            }
            RdpbcgrEncoder.EncodeBytes(dataBuffer, logonInfo.Pad);

            return dataBuffer.ToArray();
        }