コード例 #1
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
        public static NSJSValue ToObject(NSJSVirtualMachine machine, NameValueCollection s)
        {
            if (machine == null)
            {
                return(null);
            }
            NSJSObject obj = NSJSObject.New(machine);

            if (s != null)
            {
                foreach (string key in s.AllKeys)
                {
                    if (string.IsNullOrEmpty(key))
                    {
                        continue;
                    }
                    string value = s.Get(key);
                    string name  = key.ToLower();
                    if (value != null)
                    {
                        obj.Set(name, value);
                    }
                    else
                    {
                        obj.Set(name, NSJSValue.Null(machine));
                    }
                }
            }
            return(obj);
        }
コード例 #2
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
        public static NSJSValue ToObject(NSJSVirtualMachine machine, IDictionary <string, string> s)
        {
            if (machine == null)
            {
                return(null);
            }
            NSJSObject obj = NSJSObject.New(machine);

            if (s != null)
            {
                foreach (KeyValuePair <string, string> kv in s)
                {
                    if (string.IsNullOrEmpty(kv.Key))
                    {
                        continue;
                    }
                    if (kv.Value == null)
                    {
                        obj.Set(kv.Key, NSJSValue.Null(machine));
                    }
                    else
                    {
                        obj.Set(kv.Key, kv.Value);
                    }
                }
            }
            return(obj);
        }
コード例 #3
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
        public static NSJSValue ToObject(NSJSVirtualMachine machine, Cookie cookie)
        {
            if (machine == null)
            {
                return(null);
            }
            if (cookie == null)
            {
                return(NSJSValue.Null(machine));
            }
            NSJSObject objective = NSJSObject.New(machine);

            objective.Set("Comment", cookie.Comment);
            objective.Set("CommentUri", cookie.CommentUri?.ToString());
            objective.Set("Discard", cookie.Discard);
            objective.Set("Domain", cookie.Domain);
            objective.Set("Expired", cookie.Expired);
            objective.Set("Expires", cookie.Expires < NSJSDateTime.Min ? NSJSDateTime.Min : cookie.Expires);
            objective.Set("HttpOnly", cookie.HttpOnly);
            objective.Set("Name", cookie.Name);
            objective.Set("Path", cookie.Path);
            objective.Set("Port", cookie.Port);
            objective.Set("Secure", cookie.Secure);
            objective.Set("TimeStamp", cookie.TimeStamp);
            objective.Set("Value", cookie.Value);
            objective.Set("Version", cookie.Version);
            return(objective);
        }
コード例 #4
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
        public static Cookie ToCookie(NSJSValue value)
        {
            NSJSObject o = value as NSJSObject;

            if (o == null)
            {
                return(null);
            }
            Cookie cookie = new Cookie();

            cookie.Comment = ValueAuxiliary.ToString(o.Get("Comment"));
            cookie.Discard = ValueAuxiliary.ToBoolean(o.Get("Discard"));
            Uri url = default(Uri);

            if (Uri.TryCreate(ValueAuxiliary.ToString(o.Get("CommentUri")), UriKind.RelativeOrAbsolute, out url))
            {
                cookie.CommentUri = url;
            }
            cookie.Domain   = ValueAuxiliary.ToString(o.Get("Domain"));
            cookie.Expired  = ValueAuxiliary.ToBoolean(o.Get("Expired"));
            cookie.Expires  = ValueAuxiliary.ToDateTime(o.Get("Expires"));
            cookie.HttpOnly = ValueAuxiliary.ToBoolean(o.Get("HttpOnly"));
            cookie.Name     = ValueAuxiliary.ToString(o.Get("Name"));
            cookie.Path     = ValueAuxiliary.ToString(o.Get("Path"));
            cookie.Port     = ValueAuxiliary.ToString(o.Get("Port"));
            cookie.Secure   = ValueAuxiliary.ToBoolean(o.Get("Secure"));
            cookie.Value    = ValueAuxiliary.ToString(o.Get("Value"));
            cookie.Version  = ValueAuxiliary.ToInt32(o.Get("Version"));
            return(cookie);
        }
コード例 #5
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
        public static MailAddress ToMailAddress(NSJSValue value)
        {
            NSJSObject a       = value as NSJSObject;
            string     address = null;

            if (a == null)
            {
                NSJSString s = value as NSJSString;
                if (s != null)
                {
                    address = s.Value;
                    if (string.IsNullOrEmpty(address))
                    {
                        return(null);
                    }
                    return(new MailAddress(address));
                }
                return(null);
            }
            address = ValueAuxiliary.ToString(a.Get("Address"));
            if (string.IsNullOrEmpty(address))
            {
                return(null);
            }
            string displayName = ValueAuxiliary.ToString(a.Get("DisplayName"));

            return(new MailAddress(address, displayName, Encoding.UTF8));
        }
コード例 #6
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
        public static NSJSValue ToObject(NSJSVirtualMachine machine, HttpFileCollection files)
        {
            if (machine == null)
            {
                return(null);
            }
            if (files == null)
            {
                return(NSJSValue.Null(machine));
            }
            NSJSObject owner = NSJSObject.New(machine);

            foreach (string key in files.AllKeys)
            {
                if (string.IsNullOrEmpty(key))
                {
                    continue;
                }
                HttpPostedFile fileinfo = files[key];
                if (fileinfo == null)
                {
                    continue;
                }
                owner.Set(key, ToObject(machine, fileinfo));
            }
            return(owner);
        }
コード例 #7
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
 public static Attachment ToAttachment(NSJSValue value)
 {
     if (value == null)
     {
         return(null);
     }
     if (value is NSJSString)
     {
         string path = ((NSJSString)value).Value;
         if (!File.Exists(path))
         {
             return(null);
         }
         return(new Attachment(path));
     }
     if (value is NSJSObject)
     {
         NSJSObject o             = (NSJSObject)value;
         string     fileName      = o.Get("FileName").As <string>();
         string     mediaType     = o.Get("MediaType").As <string>();
         string     blobName      = o.Get("Name").As <string>();
         Stream     contentStream = NSJSStream.Get(o.Get("ContentStream") as NSJSObject);
         if (contentStream != null && !string.IsNullOrEmpty(blobName))
         {
             return(new Attachment(contentStream, blobName, mediaType));
         }
         if (!File.Exists(fileName))
         {
             return(null);
         }
         return(new Attachment(fileName, mediaType));
     }
     return(null);
 }
コード例 #8
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
        public static MailMessage ToMailMessage(NSJSValue value)
        {
            NSJSObject mail = value as NSJSObject;

            if (mail == null)
            {
                return(null);
            }
            MailMessage message = new MailMessage();

            message.Body            = ValueAuxiliary.ToString(mail.Get("Body"));
            message.Subject         = ValueAuxiliary.ToString(mail.Get("Subject"));
            message.IsBodyHtml      = ValueAuxiliary.ToBoolean(mail.Get("IsBodyHtml"));
            message.BodyEncoding    = Encoding.UTF8;
            message.HeadersEncoding = Encoding.UTF8;
            message.SubjectEncoding = Encoding.UTF8;
            MailAddress address = ToMailAddress(mail.Get("From"));

            if (address == null)
            {
                return(null);
            }
            message.From   = address;
            message.Sender = ToMailAddress(mail.Get("Sender"));
            ArrayAuxiliary.Fill(mail.Get("To"), message.To);
            ArrayAuxiliary.Fill(mail.Get("ReplyToList"), message.ReplyToList);
            ArrayAuxiliary.Fill(mail.Get("Attachments"), message.Attachments);
            return(message);
        }
コード例 #9
0
        public static NSJSValue ToArray(NSJSVirtualMachine machine, DataTable dataTable)
        {
            if (machine == null)
            {
                return(null);
            }
            DataRowCollection rows = null;
            int       count        = dataTable == null ? 0 : (rows = dataTable.Rows).Count;
            NSJSArray results      = NSJSArray.New(machine, count);

            if (count <= 0)
            {
                return(results);
            }
            IDictionary <string, int> columns = new Dictionary <string, int>();

            foreach (DataColumn column in dataTable.Columns)
            {
                columns.Add(column.ColumnName, column.Ordinal);
            }
            for (int i = 0; i < count; i++)
            {
                NSJSObject item = NSJSObject.New(machine);
                DataRow    row  = rows[i];
                results[i] = item;
                foreach (KeyValuePair <string, int> column in columns)
                {
                    object value = row[column.Value];
                    item.Set(column.Key, value.As(machine));
                }
            }
            return(results);
        }
コード例 #10
0
ファイル: ObjectAuxiliary.cs プロジェクト: liulilittle/nsjs
        public static NSJSValue ToObject(NSJSVirtualMachine machine, IPHostEntry host)
        {
            if (machine == null)
            {
                return(null);
            }
            if (host == null)
            {
                return(NSJSValue.Null(machine));
            }
            NSJSObject entry = NSJSObject.New(machine);

            entry.Set("HostName", host.HostName);
            entry.Set("AddressList", ArrayAuxiliary.ToArray(machine, host.AddressList));

            string[]  aliases = host.Aliases;
            NSJSArray array   = NSJSArray.New(machine, aliases.Length);

            for (int i = 0; i < aliases.Length; i++)
            {
                array[i] = NSJSString.New(machine, aliases[i]);
            }
            entry.Set("Aliases", array);

            return(entry);
        }
コード例 #11
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);
                        }
                    }
                });
            }
コード例 #12
0
ファイル: HttpRequest.cs プロジェクト: liulilittle/nsjs
        public static bool Close(NSJSValue request)
        {
            NSJSObject o = request as NSJSObject;

            if (o == null)
            {
                return(false);
            }
            ObjectAuxiliary.RemoveInKeyValueCollection(o.Get("InputStream") as NSJSObject);
            NSJSArray files = o.Get("Files") as NSJSArray;

            if (files != null)
            {
                foreach (NSJSValue value in files)
                {
                    if (value == null)
                    {
                        continue;
                    }
                    NSJSObject posedfile = value as NSJSObject;
                    if (posedfile == null)
                    {
                        continue;
                    }
                    ObjectAuxiliary.RemoveInKeyValueCollection(o.Get("InputStream") as NSJSObject);
                }
            }
            return(ObjectAuxiliary.RemoveInKeyValueCollection(request as NSJSObject));
        }
コード例 #13
0
ファイル: Stream.cs プロジェクト: liulilittle/nsjs
        public static NSJSObject New(NSJSVirtualMachine machine, BaseStream stream)
        {
            if (machine == null || stream == null)
            {
                return(null);
            }
            NSJSObject o = NSJSObject.New(machine);

            o.Set("CanWrite", stream.CanWrite);
            o.Set("CanSeek", stream.CanSeek);
            o.Set("CanRead", stream.CanRead);

            o.DefineProperty("Length", m_LengthProc, (NSJSFunctionCallback)null);
            o.DefineProperty("Position", m_PositionProc, m_PositionProc);
            o.Set("Seek", m_SeekProc);
            o.Set("CopyTo", m_CopyToProc);

            o.Set("Read", m_ReadProc);
            o.Set("Write", m_WriteProc);
            o.Set("Flush", m_FlushProc);
            o.Set("ReadBytes", m_ReadBytesProc);

            o.Set("Close", m_DisposeProc);
            o.Set("Dispose", m_DisposeProc);

            NSJSKeyValueCollection.Set(o, stream);
            return(o);
        }
コード例 #14
0
ファイル: Socket.cs プロジェクト: liulilittle/nsjs
 private static void ProcessConnected(object sender, SocketAsyncEventArgs e)
 {
     using (e)
     {
         try
         {
             SocketContext context = e.UserToken as SocketContext;
             do
             {
                 if (context == null)
                 {
                     break;
                 }
                 NSJSFunction function = context.ConnectedAsyncCallback;
                 NSJSObject   socket   = context.This;
                 context.ConnectedAsync         = null;
                 context.ConnectedAsyncCallback = null;
                 if (function == null)
                 {
                     break;
                 }
                 NSJSVirtualMachine machine = function.VirtualMachine;
                 if (machine == null)
                 {
                     break;
                 }
                 machine.Join((sendert, statet) => function.Call(socket, NSJSInt32.New(machine, unchecked ((int)e.SocketError))));
             } while (false);
         }
         catch (Exception) { }
     }
 }
コード例 #15
0
ファイル: WebSocketClient.cs プロジェクト: liulilittle/nsjs
        private static bool ProcessEvent(object sender, string evt, EventArgs e)
        {
            if (sender == null || string.IsNullOrEmpty(evt))
            {
                return(false);
            }
            WebSocket socket = sender as WebSocket;

            if (socket == null)
            {
                return(false);
            }
            NSJSObject websocket = Get(socket);

            if (websocket == null)
            {
                return(false);
            }
            NSJSVirtualMachine machine = websocket.VirtualMachine;

            machine.Join(delegate
            {
                NSJSFunction callback = websocket.Get(evt) as NSJSFunction;
                if (callback != null)
                {
                    NSJSObject data = WebSocketClient.GetMessageEventData(machine, e);
                    callback.Call(new NSJSValue[] { data });
                }
            });
            return(true);
        }
コード例 #16
0
ファイル: WebSocketClient.cs プロジェクト: liulilittle/nsjs
        public static NSJSObject GetMessageEventData(NSJSVirtualMachine machine, EventArgs e)
        {
            if (machine == null || e == null)
            {
                return(null);
            }
            MessageEventArgs message = e as MessageEventArgs;

            if (message == null)
            {
                return(null);
            }
            NSJSObject data = NSJSObject.New(machine);

            data.Set("IsText", message.IsText);
            if (message.IsText)
            {
                data.Set("RawData", message.Message);
            }
            else // BLOB
            {
                data.Set("RawData", message.RawData);
            }
            return(data);
        }
コード例 #17
0
        public static NSJSObject New(NSJSVirtualMachine machine, NSJSObject context, HTTPResponse response)
        {
            if (machine == null || context == null || response == null)
            {
                return(null);
            }
            NSJSObject objective = NSJSObject.New(machine);

            objective.Set("CurrentContext", context);
            objective.DefineProperty("ContentEncoding", g_ContentEncodingProc, g_ContentEncodingProc);
            objective.DefineProperty("ContentType", g_ContentTypeProc, g_ContentTypeProc);
            objective.DefineProperty("StatusDescription", g_StatusDescriptionProc, g_StatusDescriptionProc);
            objective.DefineProperty("StatusCode", g_StatusCodeProc, g_StatusCodeProc);
            objective.DefineProperty("KeepAlive", g_KeepAliveProc, g_KeepAliveProc);
            objective.DefineProperty("ProtocolVersion", g_ProtocolVersionProc, g_ProtocolVersionProc);
            objective.DefineProperty("RedirectLocation", g_RedirectLocationProc, g_RedirectLocationProc);
            objective.DefineProperty("SendChunked", g_SendChunkedProc, g_SendChunkedProc);
            objective.DefineProperty("Headers", g_HeadersProc, g_HeadersProc);
            objective.DefineProperty("Cookies", g_CookiesProc, g_CookiesProc);

            objective.Set("Redirect", g_RedirectProc);
            objective.Set("End", g_EndProc);
            objective.Set("Abort", g_AbortProc);

            objective.Set("SetCookie", g_SetCookieProc);
            objective.Set("AppendCookie", g_SetCookieProc);
            objective.Set("AddHeader", g_AddHeaderProc);
            objective.Set("AppendHeader", g_AddHeaderProc);

            objective.Set("Write", g_WriteProc);
            objective.Set("WriteFile", g_WriteFileProc);
            objective.Set("BinaryWrite", g_BinaryWriteProc);
            NSJSKeyValueCollection.Set(objective, response);
            return(objective);
        }
コード例 #18
0
        private static void Require(IntPtr info)
        {
            NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info);
            NSJSString rawUri = arguments.Length > 0 ? arguments[0] as NSJSString : null;

            if (rawUri == null || rawUri.DateType != NSJSDataType.kString)
            {
                arguments.SetReturnValue(false);
            }
            else
            {
                NSJSVirtualMachine machine = arguments.VirtualMachine;
                NSJSObject         global  = machine.Global;
                string             path    = rawUri.Value;
                string             source;
                if (string.IsNullOrEmpty(path))
                {
                    arguments.SetReturnValue(false);
                }
                else
                {
                    int index = path.IndexOf('#');
                    if (index > -1)
                    {
                        path = path.Substring(0, index);
                    }
                    index = path.IndexOf('?');
                    if (index > -1)
                    {
                        path = path.Substring(0, index);
                    }
                    do
                    {
                        bool success = false;
                        if (!FileAuxiliary.TryReadAllText(path, out source))
                        {
                            if (!FileAuxiliary.TryReadAllText(Application.StartupPath + "/" + path, out source))
                            {
                                arguments.SetReturnValue(false);
                                break;
                            }
                            success = true;
                        }
                        if (!success)
                        {
                            if (!HttpAuxiliary.TryReadAllText(path, out source))
                            {
                                arguments.SetReturnValue(false);
                                break;
                            }
                        }
                        if (File.Exists(path))
                        {
                            path = Path.GetFullPath(path);
                        }
                        arguments.SetReturnValue(machine.Run(source, path));
                    } while (false);
                }
            }
        }
コード例 #19
0
ファイル: WebSocketServer.cs プロジェクト: liulilittle/nsjs
        private static NSJSObject New(NSJSVirtualMachine machine, WebSocketListener server)
        {
            if (machine == null || server == null)
            {
                return(null);
            }
            NSJSObject objective = NSJSObject.New(machine);

            objective.Set("Port", server.Port);
            objective.Set("GetBindPort", g_GetBindPortProc);
            objective.Set("Stop", g_StopProc);
            objective.Set("Start", g_StartProc);
            objective.Set("Close", g_CloseProc);
            objective.Set("Dispose", g_CloseProc);

            server.UserToken         = objective;
            objective.CrossThreading = true;

            server.OnMessage += (websocket, e) => ProcessEvent(objective, websocket, "OnMessage", e);
            server.OnOpen    += (websocket, e) => ProcessEvent(objective, websocket, "OnOpen", e, true);
            server.OnError   += (websocket, e) => ProcessEvent(objective, websocket, "OnError", e);
            server.OnClose   += (websocket, e) => ProcessEvent(objective, websocket, "OnClose", e);

            NSJSKeyValueCollection.Set(objective, server);
            return(objective);
        }
コード例 #20
0
 public static NSJSObject New(NSJSVirtualMachine machine, ENCODING encoding)
 {
     lock (g_Locker)
     {
         if (machine == null || encoding == null)
         {
             return(null);
         }
         IDictionary <IntPtr, NSJSObject> dVirtualTables;
         if (!g_EncodingInstanceTable.TryGetValue(encoding.CodePage, out dVirtualTables))
         {
             dVirtualTables = new Dictionary <IntPtr, NSJSObject>();
             g_EncodingInstanceTable.Add(encoding.CodePage, dVirtualTables);
         }
         NSJSObject o;
         if (dVirtualTables.TryGetValue(machine.Isolate, out o))
         {
             return(o);
         }
         if (!g_UninitializedEncoding)
         {
             g_UninitializedEncoding = true;
             g_GetBytesProc          = NSJSPinnedCollection.Pinned <NSJSFunctionCallback>(GetBytes);
             g_GetStringProc         = NSJSPinnedCollection.Pinned <NSJSFunctionCallback>(GetString);
         }
         o = NSJSObject.New(machine);
         o.CrossThreading = true;
         o.Set("GetBytes", g_GetBytesProc);
         o.Set("GetString", g_GetStringProc);
         dVirtualTables.Add(machine.Isolate, o);
         NSJSKeyValueCollection.Set(o, encoding);
         return(o);
     }
 }
コード例 #21
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);
            }
コード例 #22
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);
        }
コード例 #23
0
ファイル: HttpClient.cs プロジェクト: liulilittle/nsjs
        private static bool fill2object(NSJSObject o, HttpClientResponse responset)
        {
            if (o == null || responset == null)
            {
                return(false);
            }
            NSJSVirtualMachine machine = o.VirtualMachine;

            machine.Join((sender, state) =>
            {
                o.Set("AsynchronousMode", responset.AsynchronousMode);
                o.Set("CharacterSet", responset.CharacterSet ?? string.Empty);
                o.Set("ContentLength", responset.ContentLength);
                o.Set("ContentType", responset.ContentType ?? string.Empty);
                o.Set("LastModified", NSJSDateTime.Invalid(responset.LastModified) ? NSJSDateTime.Min :
                      responset.LastModified);
                o.Set("ManualWriteToStream", responset.ManualWriteToStream);
                o.Set("ResponseUri", responset.ResponseUri == null ? string.Empty :
                      responset.ResponseUri.ToString());
                o.Set("Server", responset.Server ?? string.Empty);
                o.Set("StatusCode", unchecked ((int)responset.StatusCode));
                o.Set("ContentEncoding", responset.ContentEncoding ?? string.Empty);
                o.Set("StatusDescription", responset.StatusDescription ?? string.Empty);
            });
            return(true);
        }
コード例 #24
0
        private static void GetConfigurationView(IntPtr info)
        {
            NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info);
            string path = GetFullPath(arguments.Length > 0 ? (arguments[0] as NSJSString)?.Value : null);

            if (File.Exists(path))
            {
                NSJSObject configuration = NSJSObject.New(arguments.VirtualMachine);
                foreach (string section in GetAllSection(path))
                {
                    if (string.IsNullOrEmpty(section))
                    {
                        continue;
                    }
                    NSJSObject sectionObject = NSJSObject.New(arguments.VirtualMachine);
                    foreach (KeyValuePair <string, string> kv in GetAllKeyValue(path, section))
                    {
                        if (string.IsNullOrEmpty(kv.Key))
                        {
                            continue;
                        }
                        sectionObject.Set(kv.Key, kv.Value);
                    }
                    configuration.Set(section, sectionObject);
                }
                arguments.SetReturnValue(configuration);
            }
        }
コード例 #25
0
ファイル: HttpClient.cs プロジェクト: liulilittle/nsjs
        private static IEnumerable <HttpPostValue> array2blobs(NSJSArray array)
        {
            if (array == null)
            {
                return(null);
            }
            IList <HttpPostValue> blobs = new List <HttpPostValue>();
            int count = array.Length;

            for (int i = 0; i < count; i++)
            {
                NSJSObject o = array[i] as NSJSObject;
                if (o == null)
                {
                    continue;
                }
                HttpPostValue blob = new HttpPostValue();
                blob.FileName = (o.Get("FileName") as NSJSString)?.Value;
                NSJSBoolean boolean = o.Get("IsText") as NSJSBoolean;
                if (boolean != null)
                {
                    blob.IsText = boolean.Value;
                }
                blob.Key   = (o.Get("Key") as NSJSString)?.Value;
                blob.Value = (o.Get("Value") as NSJSUInt8Array)?.Buffer;
            }
            return(blobs);
        }
コード例 #26
0
 public static HTTPApplication GetApplication(NSJSObject application)
 {
     if (application == null)
     {
         return(null);
     }
     return(NSJSKeyValueCollection.Get <HTTPApplication>(application));
 }
コード例 #27
0
ファイル: Socket.cs プロジェクト: liulilittle/nsjs
        private static void Invalid(IntPtr info)
        {
            NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info);
            SocketContext            context   = GetSocketContext(arguments.Length > 0 ? arguments[0] as NSJSObject : null);
            NSJSObject o = NSJSObject.New(arguments.VirtualMachine);

            arguments.SetReturnValue(!(context != null && context.Socket != null && context.This != null));
        }
コード例 #28
0
 public static ENCODING GetEncoding(NSJSObject value)
 {
     if (value == null)
     {
         return(DefaultEncoding);
     }
     return(NSJSKeyValueCollection.Get <ENCODING>(value));
 }
コード例 #29
0
 public static HTTPResponse GetResponse(NSJSObject response)
 {
     if (response == null)
     {
         return(null);
     }
     return(NSJSKeyValueCollection.Get <HTTPResponse>(response));
 }
コード例 #30
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);
     });
 }