Microsoft.Protocols.TestSuites.Common.RopHardDeleteMessagesAndSubfoldersResponse.Deserialize C# (CSharp) Method

Deserialize() public method

Deserialize the ROP response buffer.
public Deserialize ( byte ropBytes, int startIndex ) : int
ropBytes byte ROPs bytes in response.
startIndex int The start index of this ROP.
return int
        public int Deserialize(byte[] ropBytes, int startIndex)
        {
            IntPtr responseBuffer = new IntPtr();
            responseBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(this));
            try
            {
                Marshal.Copy(ropBytes, startIndex, responseBuffer, Marshal.SizeOf(this));
                this = (RopHardDeleteMessagesAndSubfoldersResponse)Marshal.PtrToStructure(
                    responseBuffer, 
                    typeof(RopHardDeleteMessagesAndSubfoldersResponse));
                return Marshal.SizeOf(this);
            }
            finally
            {
                Marshal.FreeHGlobal(responseBuffer);
            }
        }
    }

Usage Example

        /// <summary>
        /// Clean up the test.
        /// </summary>
        protected override void TestCleanup()
        {
            if (this.isReceiveNewMail == true)
            {
                WebHeaderCollection headers = new WebHeaderCollection();
                MailboxResponseBodyBase response;

                #region Send a valid Connect request type to establish a Session Context with the server.
                ConnectSuccessResponseBody connectResponse = this.ConnectToServer(out headers);
                #endregion

                #region Send an Execute request that incluldes Logon ROP to server.
                WebHeaderCollection executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);

                ExecuteRequestBody requestBody = this.InitializeExecuteRequestBody(this.GetRopLogonRequest());
                List<string> metaTags = new List<string>();

                ExecuteSuccessResponseBody executeSuccessResponse = this.SendExecuteRequest(requestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;

                ulong folderId;
                RopLogonResponse logonResponse = new RopLogonResponse();
                uint logonHandle = this.ParseLogonResponse(executeSuccessResponse.RopBuffer, out folderId, out logonResponse);
                #endregion

                #region Send an Execute request to open inbox folder.
                RPC_HEADER_EXT[] rpcHeaderExts;
                byte[][] rops;
                uint[][] serverHandleObjectsTables;
                RopOpenFolderRequest openFolderRequest = this.OpenFolderRequest(logonResponse.FolderIds[4]);

                ExecuteRequestBody openFolderRequestBody = this.InitializeExecuteRequestBody(openFolderRequest, logonHandle);
                executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);
                executeSuccessResponse = this.SendExecuteRequest(openFolderRequestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;

                RopBufferHelper ropBufferHelper = new RopBufferHelper(Site);
                ropBufferHelper.ParseResponseBuffer(executeSuccessResponse.RopBuffer, out rpcHeaderExts, out rops, out serverHandleObjectsTables);
                RopOpenFolderResponse openFolderResponse = new RopOpenFolderResponse();
                openFolderResponse.Deserialize(rops[0], 0);
                 uint folderHandle = serverHandleObjectsTables[0][openFolderResponse.OutputHandleIndex];
                #endregion

                #region Send an Execute request type to hard delete messages in inbox folder.
                RopHardDeleteMessagesAndSubfoldersRequest hardDeleteRequest;
                hardDeleteRequest.RopId = (byte)RopId.RopHardDeleteMessagesAndSubfolders;
                hardDeleteRequest.LogonId = ConstValues.LogonId;

                // Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table
                // where the handle for the input Server object is stored.
                hardDeleteRequest.InputHandleIndex = 0;
                hardDeleteRequest.WantAsynchronous = 0x00; // Synchronously
                hardDeleteRequest.WantDeleteAssociated = 0xFF; // TRUE: delete all messages and subfolders
                ExecuteRequestBody hardDeleteRequestBody = this.InitializeExecuteRequestBody(hardDeleteRequest, folderHandle);
                executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);
                executeSuccessResponse = this.SendExecuteRequest(hardDeleteRequestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;
                RopHardDeleteMessagesAndSubfoldersResponse hardDeleteMessagesAndSubfoldersResponse = new RopHardDeleteMessagesAndSubfoldersResponse();
                hardDeleteMessagesAndSubfoldersResponse.Deserialize(rops[0], 0);
                #endregion

                #region Send an Execute request to open sent items folder.
                openFolderRequest = this.OpenFolderRequest(logonResponse.FolderIds[6]);

                openFolderRequestBody = this.InitializeExecuteRequestBody(openFolderRequest, logonHandle);
                executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);
                executeSuccessResponse = this.SendExecuteRequest(openFolderRequestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;

                ropBufferHelper = new RopBufferHelper(Site);
                ropBufferHelper.ParseResponseBuffer(executeSuccessResponse.RopBuffer, out rpcHeaderExts, out rops, out serverHandleObjectsTables);
                openFolderResponse = new RopOpenFolderResponse();
                openFolderResponse.Deserialize(rops[0], 0);
                folderHandle = serverHandleObjectsTables[0][openFolderResponse.OutputHandleIndex];
                #endregion

                #region Send an Execute request type to hard delete messages in sent items folder.
                hardDeleteRequest.RopId = (byte)RopId.RopHardDeleteMessagesAndSubfolders;
                hardDeleteRequest.LogonId = ConstValues.LogonId;

                // Set InputHandleIndex to 0x00, which specifies the location in the Server object handle table
                // where the handle for the input Server object is stored.
                hardDeleteRequest.InputHandleIndex = 0;
                hardDeleteRequest.WantAsynchronous = 0x00; // Synchronously
                hardDeleteRequest.WantDeleteAssociated = 0xFF; // TRUE: delete all messages and subfolders
                hardDeleteRequestBody = this.InitializeExecuteRequestBody(hardDeleteRequest, folderHandle);
                executeHeaders = AdapterHelper.InitializeHTTPHeader(RequestType.Execute, AdapterHelper.ClientInstance, AdapterHelper.Counter);
                executeSuccessResponse = this.SendExecuteRequest(hardDeleteRequestBody, ref executeHeaders, out metaTags) as ExecuteSuccessResponseBody;
                hardDeleteMessagesAndSubfoldersResponse = new RopHardDeleteMessagesAndSubfoldersResponse();
                hardDeleteMessagesAndSubfoldersResponse.Deserialize(rops[0], 0);
                #endregion

                #region Send a Disconnect request to destroy the Session Context.
                this.Adapter.Disconnect(out response);
                #endregion

                this.isReceiveNewMail = false;
            }

            base.TestCleanup();
        }
RopHardDeleteMessagesAndSubfoldersResponse