예제 #1
0
        private void PackUriResourceHandler_ReadResponse(object sender, CfxReadResponseEventArgs readResponse)
        {
            if (_StreamResourceInfo == null)
            {
                readResponse.SetReturnValue(false);
                return;
            }

            var buffer    = new byte[readResponse.BytesToRead];
            var bytesRead = _StreamResourceInfo.Stream.Read(buffer, 0, readResponse.BytesToRead);

            System.Runtime.InteropServices.Marshal.Copy(buffer, 0, readResponse.DataOut, bytesRead);
            readResponse.BytesRead = bytesRead;
            readResponse.SetReturnValue(bytesRead > 0);
        }
예제 #2
0
        void ResourceHandler_ReadResponse(object sender, CfxReadResponseEventArgs e)
        {
            int bytesToCopy = webResource.data.Length - bytesDone;

            if (bytesToCopy > e.BytesToRead)
            {
                bytesToCopy = e.BytesToRead;
            }
            Marshal.Copy(webResource.data, bytesDone, e.DataOut, bytesToCopy);
            e.BytesRead = bytesToCopy;
            bytesDone  += bytesToCopy;
            e.SetReturnValue(true);
        }
예제 #3
0
        private void PackUriResourceHandler_ReadResponse(object sender, CfxReadResponseEventArgs readResponse)
        {
            if (_StreamResourceInfo == null)
            {
                readResponse.SetReturnValue(false);
                return;
            }

            var stream    = _StreamResourceInfo.Stream;
            var buffer    = new byte[readResponse.BytesToRead];
            var bytesRead = stream.Read(buffer, 0, readResponse.BytesToRead);

            System.Runtime.InteropServices.Marshal.Copy(buffer, 0, readResponse.DataOut, bytesRead);
            readResponse.BytesRead = bytesRead;
            readResponse.SetReturnValue(true);

            if (stream.Position != stream.Length)
            {
                return;
            }

            Clean();
            _Logger?.Info(Loaded);
        }
예제 #4
0
        private void OnReadResponse(object sender, CfxReadResponseEventArgs e)
        {
            int bytesToCopy = data.Length - readResponseStreamOffset;

            if (bytesToCopy > e.BytesToRead)
            {
                bytesToCopy = e.BytesToRead;
            }

            Marshal.Copy(data, readResponseStreamOffset, e.DataOut, bytesToCopy);

            e.BytesRead = bytesToCopy;

            readResponseStreamOffset += bytesToCopy;

            e.SetReturnValue(true);

            if (readResponseStreamOffset == data.Length)
            {
                gcHandle.Free();
            }
        }