private static void WriteFile(IntPtr info) { ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments, value) => { NSJSInt32 count = null; NSJSInt32 offset = null; if (arguments.Length == 2) { count = arguments[1] as NSJSInt32; } else if (arguments.Length > 2) { offset = arguments[1] as NSJSInt32; count = arguments[2] as NSJSInt32; } int ofs = offset == null ? 0 : offset.Value; int size = count == null ? value.Length : count.Value; if (ofs < 0) { ofs = 0; } if (size < 0) { size = 0; } arguments.SetReturnValue(response.WriteFile(value, ofs, size)); }); }
private static void Close(IntPtr info) { ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) => { websocket.Close(); arguments.SetReturnValue(ObjectAuxiliary.RemoveInKeyValueCollection(arguments.This)); }); }
private static void Close(IntPtr info) { ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) => { server.Stop(); ObjectAuxiliary.RemoveInKeyValueCollection(arguments.This); }); }
public static void BeginTransaction(IntPtr info) { ObjectAuxiliary.Call <DATATableGateway>(info, (gateway, arguments) => { IDbTransaction transaction = gateway.CreateTransaction(); NSJSObject objective = DatabaseTransaction.New(arguments.VirtualMachine, transaction); arguments.SetReturnValue(objective); }); }
private static void AddHeader(IntPtr info) { ObjectAuxiliary.Call(info, (HTTPResponse response, NSJSFunctionCallbackInfo arguments, NSJSValue solt0) => { string value = ValueAuxiliary.ToString(arguments.Length > 1 ? arguments[1] : null); string name = ValueAuxiliary.ToString(solt0); arguments.SetReturnValue(response.AppendHeader(name, value)); }); }
private static void SetCookie(IntPtr info) { ObjectAuxiliary.Call(info, (HTTPResponse response, NSJSFunctionCallbackInfo arguments, NSJSValue solt0) => { bool success = false; Cookie cookie = ObjectAuxiliary.ToCookie(solt0); if (cookie != null) { success = response.SetCookie(cookie); } arguments.SetReturnValue(success); }); }
private static void Open(IntPtr info) { ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) => { try { websocket.Open(); } catch (Exception exception) { Throwable.Exception(arguments.VirtualMachine, exception); } }); }
private static void Start(IntPtr info) { ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) => { try { server.Start(); } catch (Exception exception) { Throwable.Exception(arguments.VirtualMachine, exception); } }); }
private static void InternalSend(IntPtr info, bool synchronization) { ObjectAuxiliary.Call <MailClient>(info, (smtp, arguments) => { do { NSJSVirtualMachine machine = arguments.VirtualMachine; if (arguments.Length <= 0) { Throwable.ArgumentException(machine); break; } MailMessage message = null; try { message = ObjectAuxiliary.ToMailMessage(arguments[0]); } catch (Exception exception) { Throwable.Exception(machine, exception); break; } if (message == null) { Throwable.ArgumentNullException(machine); break; } if (synchronization) { arguments.SetReturnValue(smtp.Send(message)); } else { NSJSFunction function = arguments.Length > 1 ? arguments[1] as NSJSFunction : null; Action <Exception> callbackt = null; if (function != null) { callbackt = (exception) => machine.Join((sender, state) => function.Call(new[] { Throwable.FormatMessage(exception) })); function.CrossThreading = true; } arguments.SetReturnValue(smtp.SendAsync(message, callbackt)); } } while (false); }); }
private static void Send(IntPtr info) { ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) => { bool success = false; byte[] buffer = arguments.Length > 0 ? (arguments[0] as NSJSUInt8Array)?.Buffer : null; if (buffer != null) { success = websocket.Send(buffer); } else { string message = arguments.Length > 0 ? (arguments[0] as NSJSString)?.Value : null; if (message != null) { success = websocket.Send(message); } } arguments.SetReturnValue(success); }); }
private static void RollbackOrCommit(IntPtr info, bool commiting) { ObjectAuxiliary.Call <IDbTransaction>(info, (transaction, arguments) => { try { if (commiting) { transaction.Commit(); } else { transaction.Rollback(); } } catch (Exception exception) { Throwable.Exception(arguments.VirtualMachine, exception); } }); }
private static void GetBindPort(IntPtr info) { ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) => arguments.SetReturnValue(server.GetBindPort())); }
private static void Write(IntPtr info) { ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments, value) => arguments.SetReturnValue(response.Write(value))); }
private static void Available(IntPtr info) { ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) => arguments.SetReturnValue(websocket.Available)); }
private static void Redirect(IntPtr info) { ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments, value) => response.Redirect(value)); }
private static void Abort(IntPtr info) { ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments) => response.Abort()); }
private static void Stop(IntPtr info) { ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) => server.Stop()); }