Ejemplo n.º 1
0
 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));
     });
 }
Ejemplo n.º 2
0
 private static void Close(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) =>
     {
         websocket.Close();
         arguments.SetReturnValue(ObjectAuxiliary.RemoveInKeyValueCollection(arguments.This));
     });
 }
Ejemplo n.º 3
0
 private static void Close(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) =>
     {
         server.Stop();
         ObjectAuxiliary.RemoveInKeyValueCollection(arguments.This);
     });
 }
Ejemplo n.º 4
0
 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);
     });
 }
Ejemplo n.º 5
0
 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));
     });
 }
Ejemplo n.º 6
0
 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);
     });
 }
Ejemplo n.º 7
0
 private static void Open(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) =>
     {
         try
         {
             websocket.Open();
         }
         catch (Exception exception)
         {
             Throwable.Exception(arguments.VirtualMachine, exception);
         }
     });
 }
Ejemplo n.º 8
0
 private static void Start(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) =>
     {
         try
         {
             server.Start();
         }
         catch (Exception exception)
         {
             Throwable.Exception(arguments.VirtualMachine, exception);
         }
     });
 }
Ejemplo n.º 9
0
 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);
     });
 }
Ejemplo n.º 10
0
 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);
     });
 }
Ejemplo n.º 11
0
 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);
         }
     });
 }
Ejemplo n.º 12
0
 private static void GetBindPort(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) => arguments.SetReturnValue(server.GetBindPort()));
 }
Ejemplo n.º 13
0
 private static void Write(IntPtr info)
 {
     ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments, value) => arguments.SetReturnValue(response.Write(value)));
 }
Ejemplo n.º 14
0
 private static void Available(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) => arguments.SetReturnValue(websocket.Available));
 }
Ejemplo n.º 15
0
 private static void Redirect(IntPtr info)
 {
     ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments, value) => response.Redirect(value));
 }
Ejemplo n.º 16
0
 private static void Abort(IntPtr info)
 {
     ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments) => response.Abort());
 }
Ejemplo n.º 17
0
 private static void Stop(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) => server.Stop());
 }