Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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));
        }