Exemplo n.º 1
0
 public static void Throw(NSJSVirtualMachine machine, Exception exception)
 {
     if (machine == null)
     {
         throw new ArgumentNullException("machine");
     }
     if (exception == null)
     {
         throw new ArgumentNullException("exception");
     }
     NSJSException.Throw(machine, Throwable.FormatMessage(exception));
 }
Exemplo n.º 2
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);
     });
 }