internal static void read_response(IntPtr gcHandlePtr, out int __retval, IntPtr data_out, int bytes_to_read, out int bytes_read, IntPtr callback) { var self = (CfxResourceHandler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target; if (self == null) { __retval = default(int); bytes_read = default(int); return; } var e = new CfxReadResponseEventArgs(data_out, bytes_to_read, callback); var eventHandler = self.m_ReadResponse; if (eventHandler != null) { eventHandler(self, e); } e.m_isInvalid = true; bytes_read = e.m_bytes_read; if (e.m_callback_wrapped == null) { CfxApi.cfx_release(e.m_callback); } __retval = e.m_returnValue ? 1 : 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); }
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); }
internal static void read_response(IntPtr gcHandlePtr, out int __retval, IntPtr data_out, int bytes_to_read, out int bytes_read, IntPtr callback, out int callback_release) { var self = (CfxResourceHandler)System.Runtime.InteropServices.GCHandle.FromIntPtr(gcHandlePtr).Target; if (self == null || self.CallbacksDisabled) { __retval = default(int); bytes_read = default(int); callback_release = 1; return; } var e = new CfxReadResponseEventArgs(data_out, bytes_to_read, callback); self.m_ReadResponse?.Invoke(self, e); e.m_isInvalid = true; bytes_read = e.m_bytes_read; callback_release = e.m_callback_wrapped == null? 1 : 0; __retval = e.m_returnValue ? 1 : 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(); } }
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); }