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); } } }
private static void GetEncodings(IntPtr info) { NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info); var encodings = ENCODING.GetEncodings(); arguments.SetReturnValue(ArrayAuxiliary.ToArray(arguments.VirtualMachine, encodings)); }
private static void GetHostAddresses(IntPtr info) { NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info); string hostNameOrAddress = arguments.Length > 0 ? (arguments[0] as NSJSString)?.Value : null; try { if (hostNameOrAddress == null) { Throwable.ArgumentNullException(arguments.VirtualMachine); } else if (hostNameOrAddress.Length <= 0) { Throwable.ArgumentException(arguments.VirtualMachine); } else { IPAddress[] addresses = DNS.GetHostAddresses(hostNameOrAddress); arguments.SetReturnValue(ArrayAuxiliary.ToArray(arguments.VirtualMachine, addresses)); } } catch (Exception e) { Throwable.Exception(arguments.VirtualMachine, e); } }
public static void DeriveParameters(NSJSFunctionCallbackInfo arguments) { InternalExecute(arguments, (gateway, adapter, procedure) => { try { IDbDataParameter[] parameters = adapter.GetParameters(procedure); arguments.SetReturnValue(ArrayAuxiliary.ToArray(arguments.VirtualMachine, parameters)); } catch (Exception e) { Throwable.Exception(arguments.VirtualMachine, e); } }); }
private static void GetAllSection(IntPtr info) { NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info); NSJSValue result = null; if (arguments.Length > 0) { string path = GetFullPath((arguments[0] as NSJSString)?.Value); if (File.Exists(path)) { result = ArrayAuxiliary.ToArray(arguments.VirtualMachine, GetAllSection(path)); } } arguments.SetReturnValue(NSJSValue.UndefinedMerge(arguments.VirtualMachine, result)); }
private static void GetAllKeyOrValue(IntPtr info, bool allValue) { NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info); NSJSValue result = null; if (arguments.Length > 0) { string path = GetFullPath((arguments[0] as NSJSString)?.Value); string section = (arguments[1] as NSJSString)?.Value; if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(section)) { IEnumerable <string> s = (allValue ? GetAllValue(path, section) : GetAllKey(path, section)); result = ArrayAuxiliary.ToArray(arguments.VirtualMachine, s); } } arguments.SetReturnValue(NSJSValue.UndefinedMerge(arguments.VirtualMachine, result)); }
public static NSJSObject New(NSJSVirtualMachine machine, NSJSObject context, HTTPRequest request) { if (machine == null || context == null || request == null) { return(null); } NSJSObject objective = NSJSObject.New(machine); objective.Set("HttpMethod", request.HttpMethod); objective.Set("IsLocal", request.IsLocal); objective.Set("KeepAlive", request.KeepAlive); objective.Set("ContentType", request.ContentType); objective.Set("CurrentContext", context); objective.Set("Files", ObjectAuxiliary.ToObject(machine, request.Files)); objective.Set("InputStream", NSJSValue.NullMerge(machine, NSJSStream.New(machine, request.InputStream))); objective.Set("Cookies", ArrayAuxiliary.ToArray(machine, request.Cookies)); objective.Set("RequestTraceIdentifier", request.RequestTraceIdentifier.ToString()); // "D" objective.Set("RemoteEndPoint", ObjectAuxiliary.ToObject(machine, request.RemoteEndPoint)); objective.Set("ContentEncoding", NSJSEncoding.New(machine, request.ContentEncoding ?? NSJSEncoding.DefaultEncoding)); objective.Set("Form", ObjectAuxiliary.ToObject(machine, request.Form)); objective.Set("QueryString", ObjectAuxiliary.ToObject(machine, request.QueryString)); objective.Set("ContentLength", Convert.ToDouble(request.ContentLength)); objective.Set("AcceptTypes", ArrayAuxiliary.ToArray(machine, request.AcceptTypes)); objective.Set("Path", request.Path); objective.Set("RawUrl", request.RawUrl); objective.Set("ServiceName", request.ServiceName); objective.Set("Url", request.Url?.ToString()); objective.Set("UrlReferrer", request.UrlReferrer?.ToString()); objective.Set("UserAgent", request.UserAgent); objective.Set("UserHostAddress", request.UserHostAddress); objective.Set("UserHostName", request.UserHostName); objective.Set("ProtocolVersion", request.ProtocolVersion.ToString()); objective.Set("LocalEndPoint", ObjectAuxiliary.ToObject(machine, request.LocalEndPoint)); objective.Set("UserLanguages", ArrayAuxiliary.ToArray(machine, request.UserLanguages)); return(objective); }
private static void GetActiveUdpListeners(IntPtr info) { NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info); arguments.SetReturnValue(ArrayAuxiliary.ToArray(arguments.VirtualMachine, IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners())); }
private static void InternalExecute(NSJSFunctionCallbackInfo arguments, bool nonquery) { InternalExecute(arguments, (gateway, adapter, text) => { DataTable dataTable = null; IDbCommand command = null; try { IDbTransaction transaction = null; NSJSArray parameters = null; NSJSInt32 cmdtype = null; for (int solt = 1, count = arguments.Length; solt < count && (transaction == null || cmdtype == null || parameters == null); solt++) { NSJSValue current = arguments[solt]; if (transaction == null) { transaction = DatabaseTransaction.GetTransaction(current as NSJSObject); } if (cmdtype == null) { cmdtype = current as NSJSInt32; } if (parameters == null) { parameters = current as NSJSArray; } } command = ObjectAuxiliary.ToDbCommand(adapter, text, parameters); int commandType = ValueAuxiliary.ToInt32(cmdtype); switch (commandType) { case 1: command.CommandType = CommandType.StoredProcedure; break; case 2: command.CommandType = CommandType.TableDirect; break; default: command.CommandType = CommandType.Text; break; } command.Transaction = transaction; if (nonquery) { arguments.SetReturnValue(gateway.ExecuteNonQuery(command)); } else { dataTable = gateway.Select(command); arguments.SetReturnValue(ArrayAuxiliary.ToArray(arguments.VirtualMachine, dataTable)); } } catch (Exception e) { Throwable.Exception(arguments.VirtualMachine, e); } if (dataTable != null) { dataTable.Dispose(); } if (command != null) { command.Dispose(); } }); }
public virtual IEnumerable <string> GetPropertyNames() { NSJSFunction function = this.GetFrameworkFunction(RUNTIME_GETPROPERTYNAMES_PROPERTYKEY); return(ArrayAuxiliary.ToStringList(function.Call(this))); }
private static void Cookies(IntPtr info) { ObjectAuxiliary.GetOrSetProperty <HTTPResponse>(info, (response, arguments) => arguments.SetReturnValue(ArrayAuxiliary.ToArray(arguments.VirtualMachine, response.Cookies)), (response, arguments, value) => ArrayAuxiliary.Fill(value, response.Cookies)); }