private static void Start(IntPtr info) { NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info); HTTPApplication application = GetApplication(arguments.This); if (application == null) { Throwable.ObjectDisposedException(arguments.VirtualMachine); } else { try { IList <string> prefixes = ArrayAuxiliary.ToStringList(arguments.Length > 0 ? arguments[0] : null); do { if (prefixes.IsNullOrEmpty()) { Throwable.ArgumentNullException(arguments.VirtualMachine); break; } application.Start(prefixes); arguments.SetReturnValue(true); } while (false); } catch (Exception e) { Throwable.Exception(arguments.VirtualMachine, e); } } }
public static NSJSObject New(NSJSVirtualMachine machine, HTTPApplication application) { if (machine == null || application == null) { return(null); } NSJSObject objective = NSJSObject.New(machine); objective.DefineProperty("Name", g_NameProc, g_NameProc); objective.DefineProperty("Root", g_RootProc, g_RootProc); objective.Set("Start", g_StartProc); objective.Set("Stop", g_StopProc); objective.Set("Close", g_CloseProc); objective.Set("Dispose", g_CloseProc); application.Tag = objective; objective.CrossThreading = true; application.Handler = new HttpHandler(objective, application); application.EndProcessRequest += g_EndProcessRequestProc; application.BeginProcessRequest += g_BeginProcessRequestProc; NSJSKeyValueCollection.Set(objective, application); return(objective); }
public HttpHandler(NSJSObject source, HTTPApplication application) { if (source == null) { throw new ArgumentNullException("source"); } if (application == null) { throw new ArgumentNullException("application"); } source.CrossThreading = true; this.Source = source; this.Application = application; }
private static void Stop(IntPtr info) { NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info); HTTPApplication application = GetApplication(arguments.This); if (application == null) { Throwable.ObjectDisposedException(arguments.VirtualMachine); } else { application.Stop(); arguments.SetReturnValue(true); } }
private static void Root(IntPtr info) { NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info); HTTPApplication application = GetApplication(arguments.This); if (application == null) { arguments.SetReturnValue(NSJSValue.Undefined(arguments.VirtualMachine)); } else if (arguments.Length > 0) { string path = (arguments[0] as NSJSString)?.Value; application.Root = path; } else { arguments.SetReturnValue(application.Root); } }
private static void DoProcessRequest(object sender, Action <HTTPApplication, NSJSObject, NSJSVirtualMachine> callback) { if (callback == null) { throw new ArgumentNullException("callback"); } HTTPApplication application = sender as HTTPApplication; if (application == null) { return /* false */; } NSJSObject origin = application.Tag as NSJSObject; if (origin == null) { return /* false */; } NSJSVirtualMachine machine = origin.VirtualMachine; machine.Join((M, X) => callback(application, origin, machine)); }