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

Clone() public method

Create an instance of the class that is identical to the current PDU.
public Clone ( ) : StackPacket
return StackPacket
        public override StackPacket Clone()
        {
            Server_Save_Session_Info_Pdu cloneServerSaveSessionInfo = new Server_Save_Session_Info_Pdu();

            cloneServerSaveSessionInfo.commonHeader = commonHeader.Clone();
            cloneServerSaveSessionInfo.saveSessionInfoPduData = saveSessionInfoPduData;

            if (cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData.GetType()
                == typeof(TS_LOGON_INFO_VERSION_2))
            {
                TS_LOGON_INFO_VERSION_2 version2 =
                    (TS_LOGON_INFO_VERSION_2)cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData;
                version2.Pad = RdpbcgrUtility.CloneByteArray(version2.Pad);
                cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData = version2;
            }
            else if (cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData.GetType()
                == typeof(TS_PLAIN_NOTIFY))
            {
                TS_PLAIN_NOTIFY notify = (TS_PLAIN_NOTIFY)cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData;
                notify.Pad = RdpbcgrUtility.CloneByteArray(notify.Pad);
                cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData = notify;
            }
            else if (cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData.GetType()
                == typeof(TS_LOGON_INFO_EXTENDED))
            {
                TS_LOGON_INFO_EXTENDED extended =
                    (TS_LOGON_INFO_EXTENDED)cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData;
                extended.Pad = RdpbcgrUtility.CloneByteArray(extended.Pad);

                TS_LOGON_INFO_EXTENDED srcInfo = (TS_LOGON_INFO_EXTENDED)saveSessionInfoPduData.infoData;
                if (srcInfo.LogonFields != null)
                {
                    TS_LOGON_INFO_FIELD[] logonFields = new TS_LOGON_INFO_FIELD[srcInfo.LogonFields.Length];
                    for (int i = 0; i < srcInfo.LogonFields.Length; ++i)
                    {
                        logonFields[i] = srcInfo.LogonFields[i];
                        if (srcInfo.LogonFields[i].FieldData != null)
                        {
                            if (srcInfo.LogonFields[i].FieldData.GetType() == typeof(TS_LOGON_ERRORS_INFO))
                            {
                                logonFields[i].FieldData = new TS_LOGON_ERRORS_INFO();
                                ((TS_LOGON_ERRORS_INFO)logonFields[i].FieldData).ErrorNotificationData =
                                    ((TS_LOGON_ERRORS_INFO)srcInfo.LogonFields[i].FieldData).ErrorNotificationData;
                                ((TS_LOGON_ERRORS_INFO)logonFields[i].FieldData).ErrorNotificationType =
                                    ((TS_LOGON_ERRORS_INFO)srcInfo.LogonFields[i].FieldData).ErrorNotificationType;
                            }
                            else if (srcInfo.LogonFields[i].FieldData.GetType() == typeof(ARC_SC_PRIVATE_PACKET))
                            {
                                logonFields[i].FieldData = new ARC_SC_PRIVATE_PACKET();
                                ((ARC_SC_PRIVATE_PACKET)logonFields[i].FieldData).cbLen =
                                    ((ARC_SC_PRIVATE_PACKET)srcInfo.LogonFields[i].FieldData).cbLen;
                                ((ARC_SC_PRIVATE_PACKET)logonFields[i].FieldData).LogonId =
                                    ((ARC_SC_PRIVATE_PACKET)srcInfo.LogonFields[i].FieldData).LogonId;
                                ((ARC_SC_PRIVATE_PACKET)logonFields[i].FieldData).Version =
                                    ((ARC_SC_PRIVATE_PACKET)srcInfo.LogonFields[i].FieldData).Version;
                                ((ARC_SC_PRIVATE_PACKET)logonFields[i].FieldData).ArcRandomBits =
                                    RdpbcgrUtility.CloneByteArray(
                                    ((ARC_SC_PRIVATE_PACKET)srcInfo.LogonFields[i].FieldData).ArcRandomBits);
                            }
                        }
                    }

                    extended.LogonFields = logonFields;
                    cloneServerSaveSessionInfo.saveSessionInfoPduData.infoData = extended;
                }
            }

            return cloneServerSaveSessionInfo;
        }