Serialize() public method

Serialize the ROP request buffer.
public Serialize ( ) : byte[]
return byte[]
        /// <summary>
        /// Identifies that a set of IDs either belongs to deleted messages in the specified folder or will never be used for any messages in the specified folder.
        /// </summary>
        /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
        /// <param name="folderhandleIndex">A Folder object handle index.</param>
        /// <param name="longTermIdRangeIndex">An array of LongTermIdRange structures defines a range of IDs, which are reported as unused or deleted.</param>
        /// <returns>Indicate the result of this ROP operation.</returns>
        public RopResult SetLocalReplicaMidsetDeleted(int serverId, int folderhandleIndex, Sequence<int> longTermIdRangeIndex)
        {
            // Initialize ROP data.
            RopResult result = RopResult.InvalidParameter;
            uint folderHandle = this.handleContainer[folderhandleIndex];
            LongTermIdRange[] idranges = new LongTermIdRange[longTermIdRangeIndex.Count];

            // Get the Mid need to be deleted.
            for (int i = 0; i < longTermIdRangeIndex.Count; i++)
            {
                LongTermId max = new LongTermId();
                LongTermId min = new LongTermId();

                // Max Mid
                max.DatabaseGuid = this.serverReplicaGuid.ToByteArray();
                max.GlobalCounter = new byte[6];
                Array.Copy(this.localId, 0, max.GlobalCounter, 0, 6);
                byte[] sub = new byte[4];
                Array.Copy(max.GlobalCounter, 2, sub, 0, 4);
                Array.Reverse(sub);
                int num = BitConverter.ToInt32(sub, 0);

                // Make the Mid to the mid to be deleted one.
                num += longTermIdRangeIndex[i];
                sub = BitConverter.GetBytes(num);
                Array.Reverse(sub);
                Array.Copy(sub, 0, max.GlobalCounter, 2, 4);

                // Min Mid
                min.DatabaseGuid = this.serverReplicaGuid.ToByteArray();
                min.GlobalCounter = new byte[6];
                Array.Copy(this.localId, 0, min.GlobalCounter, 0, 6);
                sub = new byte[4];
                Array.Copy(min.GlobalCounter, 2, sub, 0, 4);
                Array.Reverse(sub);
                num = BitConverter.ToInt32(sub, 0);

                // Make the Mid to the mid to be deleted one.
                num += longTermIdRangeIndex[i];
                sub = BitConverter.GetBytes(num);
                Array.Reverse(sub);
                Array.Copy(sub, 0, min.GlobalCounter, 2, 4);

                // ID range data
                idranges[i].MaxLongTermId = max.Serialize();
                idranges[i].MinLongTermId = min.Serialize();
            }

            // Construct the RopGetLocalReplicaIds request.
            RopSetLocalReplicaMidsetDeletedRequest req = new RopSetLocalReplicaMidsetDeletedRequest
            {
                RopId = 0x93
            };
            byte logonId = 0;
            req.LogonId = logonId;
            req.InputHandleIndex = 0;
            req.DataSize = (ushort)((sizeof(byte) * 48 * idranges.Length) + 4);
            req.LongTermIdRangeCount = (uint)idranges.Length;

            // Set idCount, which specifies the number of IDs to reserve,
            req.LongTermIdRanges = idranges;

            // Send request and get response.
            RopSetLocalReplicaMidsetDeletedResponse setLocalReplicaMidsetDeletedResponse = (RopSetLocalReplicaMidsetDeletedResponse)this.Process(serverId, req, folderHandle);
            result = (RopResult)setLocalReplicaMidsetDeletedResponse.ReturnValue;

            if (result == RopResult.Success)
            {
                // Verify ROP SetLocalReplicaMidsetDeleted
                this.VerifyRopSetLocalReplicaMidsetDeleted(setLocalReplicaMidsetDeletedResponse);
            }

            return result;
        }