Microsoft.Protocols.TestSuites.MS_OXCPRPT.MS_OXCPRPTAdapter.RopCopyToStreamMethod C# (CSharp) Method

RopCopyToStreamMethod() public method

This method is used to copy a specified number of bytes from the current seek pointer in the source stream to the current seek pointer in the destination stream.
public RopCopyToStreamMethod ( bool isDestinationExist, bool &isReadWriteSuccess, CPRPTErrorCode &error ) : void
isDestinationExist bool Specified the whether the destination existed.
isReadWriteSuccess bool When call success:The server MUST read the number of BYTES /// requested from the source Stream object, and write those bytes into the destination Stream object .
error CPRPTErrorCode If Destination object does not exist .Expect DestinationNullObject error.
return void
        public void RopCopyToStreamMethod(bool isDestinationExist, out bool isReadWriteSuccess, out CPRPTErrorCode error)
        {
            isReadWriteSuccess = false;
            error = CPRPTErrorCode.None;

            // The source handle.
            uint firstHandle = this.cprptFirstHandle;

            // The destination handle.
            uint secondHandle = InvalidHandle;
            if (isDestinationExist)
            {
                secondHandle = this.cprptSecondHandle;
            }

            RopGetStreamSizeResponse getStreamSizeRes = this.RopGetStreamSize(firstHandle, true);
            ulong byteCount = getStreamSizeRes.StreamSize;

            // Set position of the source handle to the beginning of stream.
            this.RopSeekStream(firstHandle, (byte)Origin.Beginning, ConstValues.RopSeekStreamOffsetZero, true);
            if (isDestinationExist)
            {
                // Set position of the destination handle to the beginning of stream.
                this.RopSeekStream(secondHandle, (byte)Origin.Beginning, ConstValues.RopSeekStreamOffsetZero, true);
            }

            RopCopyToStreamResponse copyToStreamResponse = this.RopCopyToStream(firstHandle, secondHandle, (byte)HandleIndex.FirstIndex, (byte)HandleIndex.SecondIndex, byteCount);
            bool isCopyRightDataCount = false;
            if (isDestinationExist)
            {
                isCopyRightDataCount = byteCount == copyToStreamResponse.WrittenByteCount;
            }

            bool destHandleIsRight = false;
            if (copyToStreamResponse.ReturnValue.Equals((uint)CPRPTErrorCode.NullDestinationObject))
            {
                destHandleIsRight = copyToStreamResponse.DestHandleIndex == (uint)HandleIndex.SecondIndex;
            }

            this.VerifyRopCopyToStream(copyToStreamResponse, isDestinationExist, isCopyRightDataCount, destHandleIsRight);

            if (copyToStreamResponse.ReturnValue == (uint)CPRPTErrorCode.None)
            {
                isReadWriteSuccess = true;
            }

            if (copyToStreamResponse.ReturnValue == (uint)CPRPTErrorCode.NullDestinationObject)
            {
                isReadWriteSuccess = false;
                error = CPRPTErrorCode.NullDestinationObject;
            }
        }
MS_OXCPRPTAdapter