예제 #1
0
            public static NSJSObject NewContextObject(NSJSVirtualMachine machine,
                                                      NSJSObject application,
                                                      HTTPContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }
                if (application == null)
                {
                    throw new ArgumentNullException("application");
                }
                if (machine == null)
                {
                    throw new ArgumentNullException("machine");
                }
                NSJSObject objective = NSJSObject.New(machine); // ctx

                objective.Set("Application", application);
                objective.Set("Close", m_CloseProc);
                objective.Set("Dispose", m_CloseProc);
                objective.Set("Request", HttpRequest.New(machine, objective, context.Request));
                objective.Set("Response", HttpResponse.New(machine, objective, context.Response));
                objective.DefineProperty("Asynchronous", m_AsynchronousProc, m_AsynchronousProc);
                NSJSKeyValueCollection.Set(objective, context);
                return(objective);
            }
예제 #2
0
            public void ProcessRequest(HTTPContext context)
            {
                if (context == null)
                {
                    return /*undefined*/;
                }
                NSJSVirtualMachine machine = this.GetVirtualMachine();

                machine.Join((sender, state) =>
                {
                    NSJSFunction function = this.GetProcessRequestCallback();
                    if (function != null)
                    {
                        NSJSObject context_object = null;
                        try
                        {
                            context_object = this.NewContextObject(context);
                        }
                        catch (Exception) { /*-----*/ }
                        if (context_object != null)
                        {
                            function.Call(context_object);
                        }
                    }
                });
            }
예제 #3
0
 private static void OnEndProcessRequest(object sender, HTTPContext e)
 {
     DoProcessRequest(sender, (application, origin, machine) =>
     {
         NSJSFunction callback = origin.Get("EndProcessRequest") as NSJSFunction;
         if (callback != null)
         {
             callback.Call(HttpHandler.NewContextObject(machine, origin, e));
         }
     });
 }
예제 #4
0
 public NSJSObject NewContextObject(HTTPContext context)
 {
     return(NewContextObject(this.GetVirtualMachine(), this.Source, context));
 }