public static void CheckObjectCoercible(Engine engine, JsValue o) { if (o == Undefined.Instance || o == Null.Instance) { throw new JavaScriptException(engine.TypeError); } }
public string Call6(Func<JsValue, JsValue[], JsValue> callback) { var thisArg = new JsValue("bar"); var arguments = new JsValue[] { 1, "foo" }; return callback(thisArg, arguments).ToString(); }
public static Nullable<Int32> ToOptionalInt32(JsValue arg) { if (arg.IsNumber()) return TypeConverter.ToInt32(arg); return null; }
public void AddRecurring(int Hours, int Minutes, int Seconds, Jint.Native.JsValue Func) { lock (syncRoot) { recurList.Add(new RecurringFunction(Hours, Minutes, Seconds, Func)); } }
public RavenJObject ToRavenJObject(JsValue jsObject, string propertyKey = null, bool recursiveCall = false) { var objectInstance = jsObject.AsObject(); if (objectInstance.Class == "Function") { // getting a Function instance here, // means that we couldn't evaulate it using Jint return null; } var rjo = new RavenJObject(); foreach (var property in objectInstance.Properties) { if (property.Key == Constants.ReduceKeyFieldName || property.Key == Constants.DocumentIdFieldName) continue; var value = property.Value.Value; if (value.HasValue == false) continue; if (value.Value.IsRegExp()) continue; var recursive = jsObject == value; if (recursiveCall && recursive) rjo[property.Key] = null; else rjo[property.Key] = ToRavenJToken(value.Value, CreatePropertyKey(property.Key, propertyKey), recursive); } return rjo; }
public void AddAt(int Hours, int Minutes, Jint.Native.JsValue Func) { lock (syncRoot) { runAtList.Add(new RunAt(Hours, Minutes, Func)); } }
public string Call5(Delegate callback) { var thisArg = JsValue.Undefined; var arguments = new JsValue[] { 1, "foo" }; return callback.DynamicInvoke(thisArg, arguments).ToString(); }
internal static object ConvertJsValueToNetObject(Jint.Native.JsValue v) { if (v.IsBoolean()) { return(v.AsBoolean()); } if (v.IsNumber()) { return(v.AsNumber()); } if (v.IsNull()) { return(null); } if (v.IsUndefined()) { return("undefined"); } if (v.IsString()) { return(v.AsString()); } if (v.IsObject()) { return(v.ToObject()); } throw new ArgumentException(string.Format("Cannot get display value for JsValue")); }
public void Ready() { try { if (!_Pebble.EventListeners.ContainsKey("ready")) { return; } var jsfunction = _Pebble.EventListeners["ready"]; System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue> _func = jsfunction as System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue>; Jint.Native.JsValue A = new JsValue(1); Jint.Native.JsValue[] B = new Jint.Native.JsValue[1]; Jint.Native.Json.JsonParser _jsp = new Jint.Native.Json.JsonParser(_JintEngine); B[0] = _jsp.Parse("{}"); Jint.Native.JsValue C = _func.Invoke(A, B); } catch (Jint.Runtime.JavaScriptException exp) { String Exception = String.Format("{0}" + Environment.NewLine + "Line: {1}" + Environment.NewLine + "Source: {2}", exp.Message, exp.LineNumber, _JavascriptLines[exp.LineNumber - 1]); throw new System.Exception(Exception); } catch (Exception exp) { throw exp; } }
public JsValue Call(JsValue thisObject, JsValue[] arguments) { // direct calls on a NamespaceReference constructor object is creating a generic type var genericTypes = new Type[arguments.Length]; for (int i = 0; i < arguments.Length; i++) { var genericTypeReference = arguments.At(i); if (genericTypeReference == Undefined.Instance || !genericTypeReference.IsObject() || genericTypeReference.AsObject().Class != "TypeReference") { throw new JavaScriptException(Engine.TypeError, "Invalid generic type parameter"); } genericTypes[i] = arguments.At(0).As<TypeReference>().Type; } var typeReference = GetPath(_path + "`" + arguments.Length.ToString(CultureInfo.InvariantCulture)).As<TypeReference>(); if (typeReference == null) { return Undefined.Instance; } var genericType = typeReference.Type.MakeGenericType(genericTypes); return TypeReference.CreateTypeReference(Engine, genericType); }
private JsValue[] ProcessParamsArrays(JsValue[] jsArguments, IEnumerable<MethodInfo> methodInfos) { foreach (var methodInfo in methodInfos) { var parameters = methodInfo.GetParameters(); if (!parameters.Any(p => Attribute.IsDefined(p, typeof(ParamArrayAttribute)))) continue; var nonParamsArgumentsCount = parameters.Length - 1; if (jsArguments.Length < nonParamsArgumentsCount) continue; var newArgumentsCollection = jsArguments.Take(nonParamsArgumentsCount).ToList(); var argsToTransform = jsArguments.Skip(nonParamsArgumentsCount).ToList(); if (argsToTransform.Count == 1 && argsToTransform.FirstOrDefault().IsArray()) continue; var jsArray = Engine.Array.Construct(Arguments.Empty); Engine.Array.PrototypeObject.Push(jsArray, argsToTransform.ToArray()); newArgumentsCollection.Add(new JsValue(jsArray)); return newArgumentsCollection.ToArray(); } return jsArguments; }
public override void Put(string propertyName, JsValue value, bool throwOnError) { if (!CanPut(propertyName)) { if (throwOnError) { throw new JavaScriptException(Engine.TypeError); } return; } var ownDesc = GetOwnProperty(propertyName); if (ownDesc == null) { if (throwOnError) { throw new JavaScriptException(Engine.TypeError, "Unknown member: " + propertyName); } else { return; } } ownDesc.Value = value; }
internal JToken ConvertBack(JsValue value) { switch (value.Type) { case Jint.Runtime.Types.None: throw new NotSupportedException(); case Jint.Runtime.Types.Undefined: return JValue.CreateUndefined(); case Jint.Runtime.Types.Null: return JValue.CreateNull(); case Jint.Runtime.Types.Boolean: return new JValue(value.AsBoolean()); case Jint.Runtime.Types.String: return JValue.CreateString(value.AsString()); case Jint.Runtime.Types.Number: return new JValue(value.AsNumber()); case Jint.Runtime.Types.Object: var ntsObjectInstance = value.AsObject() as NTSObjectInstance; if (ntsObjectInstance != null) return ntsObjectInstance.root; return new JObject(value.AsObject().Properties.Where(kvp => !kvp.Value.Enumerable.HasValue || kvp.Value.Enumerable.Value).Select(kvp => new JProperty(kvp.Key, ConvertBack(kvp.Value.Value ?? JsValue.Undefined)))); default: throw new NotSupportedException(); } }
private void ExecuteError(int errcode, string errmessage) { try { System.Diagnostics.Debug.WriteLine("GeoLocation.ExecuteError"); System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue> _func = _funcError as System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue>; Jint.Native.Function.ScriptFunctionInstance JintScript = _func.Target as Jint.Native.Function.ScriptFunctionInstance; Jint.Engine _JintEngine = JintScript.Engine; JsValue A = new JsValue(1); JsValue[] B = new Jint.Native.JsValue[1]; Jint.Native.Json.JsonParser _jsp = new Jint.Native.Json.JsonParser(_JintEngine); String FormatString = "{{\"code\":{0}, \"message\":\"{1}\"}}"; String Error = String.Format(FormatString, errcode, errmessage); B[0] = _jsp.Parse(Error); _func.Invoke(A, B); } catch (Exception exp) { System.Diagnostics.Debug.WriteLine("Exception" + exp.Message); } }
public static JsValue Compare(JsValue x, JsValue y, bool leftFirst = true) { JsValue px, py; if (leftFirst) { px = TypeConverter.ToPrimitive(x, Types.Number); py = TypeConverter.ToPrimitive(y, Types.Number); } else { py = TypeConverter.ToPrimitive(y, Types.Number); px = TypeConverter.ToPrimitive(x, Types.Number); } var typea = px.Type; var typeb = py.Type; if (typea != Types.String || typeb != Types.String) { var nx = TypeConverter.ToNumber(px); var ny = TypeConverter.ToNumber(py); if (double.IsNaN(nx) || double.IsNaN(ny)) { return Undefined.Instance; } if (nx.Equals(ny)) { return false; } if (double.IsPositiveInfinity(nx)) { return false; } if (double.IsPositiveInfinity(ny)) { return true; } if (double.IsNegativeInfinity(ny)) { return false; } if (double.IsNegativeInfinity(nx)) { return true; } return nx < ny; } else { return String.CompareOrdinal(TypeConverter.ToString(x), TypeConverter.ToString(y)) < 0; } }
private JsValue ToString(JsValue thisObj, JsValue[] arguments) { var func = thisObj.TryCast<FunctionInstance>(); if (func == null) throw new JavaScriptException(Engine.TypeError, "Function object expected."); var officialName = _method.GetOfficialName(); return string.Format("function {0} () {{ [native code] }}", officialName); }
JsValue Log(JsValue ctx, JsValue[] args) { var strs = new String[args.Length]; for (var i = 0; i < args.Length; i++) strs[i] = args[i].ToString(); Console.WriteLine(String.Join(", ", strs)); return JsValue.Undefined; }
public bool TryConvert(object value, out JsValue result) { if (value is bool) { result = !(bool) value; return true; } result = JsValue.Null; return false; }
private static string GetErrorMessage(JsValue error) { if (error.IsObject()) { var oi = error.AsObject(); var message = oi.Get("message").AsString(); return message; } else return string.Empty; }
public bool TryConvert(object value, out JsValue result) { if (value is Enum) { result = value.ToString(); return true; } result = JsValue.Null; return false; }
public static IDictionary<String, Object> ToObjBag(JsValue arg) { var obj = arg.AsObject(); var dict = new Dictionary<String, Object>(); var properties = obj.GetOwnProperties(); foreach (var property in properties) dict.Add(property.Key, property.Value.Value.Clr()); return dict; }
public override JsValue Call(JsValue thisObject, JsValue[] arguments) { try { var result = _func(thisObject, arguments); return result; } catch (InvalidCastException) { throw new JavaScriptException(Engine.TypeError); } }
public ObjectInstance Construct(JsValue[] arguments) { if (arguments.Length == 0 && Type.IsValueType()) { var instance = Activator.CreateInstance(Type); var result = TypeConverter.ToObject(Engine, JsValue.FromObject(Engine, instance)); return result; } var constructors = Type.GetConstructors(BindingFlags.Public | BindingFlags.Instance); var methods = TypeConverter.FindBestMatch(Engine, constructors, arguments).ToList(); foreach (var method in methods) { var parameters = new object[arguments.Length]; try { for (var i = 0; i < arguments.Length; i++) { var parameterType = method.GetParameters()[i].ParameterType; if (parameterType == typeof(JsValue)) { parameters[i] = arguments[i]; } else { parameters[i] = Engine.ClrTypeConverter.Convert( arguments[i].ToObject(), parameterType, CultureInfo.InvariantCulture); } } var constructor = (ConstructorInfo)method; var instance = constructor.Invoke(parameters.ToArray()); var result = TypeConverter.ToObject(Engine, JsValue.FromObject(Engine, instance)); // todo: cache method info return result; } catch { // ignore method } } throw new JavaScriptException(Engine.TypeError, "No public methods with the specified arguments were found."); }
/// <summary> /// Creates a JavaScript recurring function, with the specified /// hours minutes and seconds which runs the supplied function. /// </summary> public RecurringFunction(int Hours, int Minutes, int Seconds, Jint.Native.JsValue Func) { this.RecurrenceID = Guid.NewGuid(); this.Function = Func; this.Seconds += Hours * 3600; this.Seconds += Minutes * 60; this.Seconds += Seconds; this.NextRunTime = DateTime.UtcNow.Add(TimeSpan.FromSeconds(this.Seconds)); //Console.WriteLine("jist recurring: Recurring Func {0}: next run time {1}", this.RecurrenceID, this.NextRunTime); }
public static IEnumerable<MethodBase> FindBestMatch(Engine engine, MethodBase[] methods, JsValue[] arguments) { methods = methods .Where(m => m.GetParameters().Count() == arguments.Length || (m.IsGenericMethodDefinition && m.GetGenericArguments().Count() == arguments.Length)) .ToArray(); if (methods.Length == 1 && !methods[0].GetParameters().Any()) { yield return methods[0]; yield break; } var objectArguments = arguments.Select(x => x.ToObject()).ToArray(); foreach (var method in methods) { var perfectMatch = true; var parameters = method.GetParameters(); for (var i = 0; i < arguments.Length; i++) { var arg = objectArguments[i]; var paramType = parameters[i].ParameterType; if (arg == null) { if (!TypeIsNullable(paramType)) { perfectMatch = false; break; } } else if (arg.GetType() != paramType) { perfectMatch = false; break; } } if (perfectMatch) { yield return method; yield break; } } foreach (var method in methods) { yield return method; } }
/// <summary> /// http://www.ecma-international.org/ecma-262/5.1/#sec-9.1 /// </summary> /// <param name="input"></param> /// <param name="preferredType"></param> /// <returns></returns> public static JsValue ToPrimitive(JsValue input, Types preferredType = Types.None) { if (input == Null.Instance || input == Undefined.Instance) { return input; } if (input.IsPrimitive()) { return input; } return input.AsObject().DefaultValue(preferredType); }
public ObjectInstance Construct(JsValue[] arguments) { try { var parameters = _engine.BuildArgs(_constructor, arguments); var obj = _constructor.Invoke(parameters); return _engine.GetDomNode(obj); } catch { throw new JavaScriptException(_engine.Jint.Error); } }
public static JsValue[] ToJsValueArray(this object[] args, Jint.Engine jsEngine) { JsValue[] jsValues = null; if (args == null) { return new JsValue[] { JsValue.Undefined }; } jsValues = new JsValue[args.Length]; for (int i = 0; i < args.Length; i++) { jsValues[i] = JsValue.FromObject(jsEngine, args[i]); } return jsValues; }
public override void SetMutableBinding(string name, JsValue value, bool strict) { var binding = _bindings[name]; if (binding.Mutable) { binding.Value = value; } else { if (strict) { throw new JavaScriptException(_engine.TypeError, "Can't update the value of an immutable binding."); } } }
public PropertyDescriptor(JsValue? get, JsValue? set, bool? enumerable = null, bool? configurable = null) { Get = get; Set = set; if (enumerable.HasValue) { Enumerable = new JsValue(enumerable.Value); } if (configurable.HasValue) { Configurable = new JsValue(configurable.Value); } }
public void ShouldBeADate() { var value = new JsValue(new DateInstance(null)); Assert.Equal(false, value.IsBoolean()); Assert.Equal(false, value.IsArray()); Assert.Equal(true, value.IsDate()); Assert.Equal(false, value.IsNull()); Assert.Equal(false, value.IsNumber()); Assert.Equal(true, value.IsObject()); Assert.Equal(false, value.IsPrimitive()); Assert.Equal(false, value.IsRegExp()); Assert.Equal(false, value.IsString()); Assert.Equal(false, value.IsUndefined()); Assert.Equal(true, value.AsDate() != null); }
public void WebViewClosed(String Data) { try { if (!_Pebble.EventListeners.ContainsKey("webviewclosed")) { return; } var jsfunction = _Pebble.EventListeners["webviewclosed"]; String Argument = Data; String[] Result = Data.Split("#".ToCharArray()); if (Result.Count() > 1) { Argument = Result[1]; System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue> _func = jsfunction as System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue>; Jint.Native.JsValue A = new JsValue(1); Jint.Native.JsValue[] B = new Jint.Native.JsValue[1]; Jint.Native.Json.JsonParser _jsp = new Jint.Native.Json.JsonParser(_JintEngine); String JSON = String.Format("{{\"response\":\"{0}\"}}", Uri.EscapeUriString(Uri.UnescapeDataString(Argument))); Jint.Native.JsValue _eValue = _jsp.Parse(JSON); B[0] = _eValue; Jint.Native.JsValue C = _func.Invoke(A, B); } } catch (Jint.Runtime.JavaScriptException exp) { String Exception = String.Format("{0}" + Environment.NewLine + "Line: {1}" + Environment.NewLine + "Source: {2}", exp.Message, exp.LineNumber, _JavascriptLines[exp.LineNumber - 1]); throw new System.Exception(Exception); } catch (Exception exp) { throw exp; } }
public JsValue Invoke(MethodInfo[] methodInfos, JsValue thisObject, JsValue[] jsArguments) { var arguments = ProcessParamsArrays(jsArguments, methodInfos); var methods = TypeConverter.FindBestMatch(Engine, methodInfos, arguments).ToList(); var converter = Engine.ClrTypeConverter; foreach (var method in methods) { var parameters = new object[arguments.Length]; var argumentsMatch = true; for (var i = 0; i < arguments.Length; i++) { var parameterType = method.GetParameters()[i].ParameterType; if (parameterType == typeof(JsValue)) { parameters[i] = arguments[i]; } else { if (!converter.TryConvert(arguments[i].ToObject(), parameterType, CultureInfo.InvariantCulture, out parameters[i])) { argumentsMatch = false; break; } var lambdaExpression = parameters[i] as LambdaExpression; if (lambdaExpression != null) { parameters[i] = lambdaExpression.Compile(); } } } if (!argumentsMatch) { continue; } // todo: cache method info return JsValue.FromObject(Engine, method.Invoke(thisObject.ToObject(), parameters.ToArray())); } throw new JavaScriptException(Engine.TypeError, "No public methods with the specified arguments were found."); }
/// <summary> /// http://www.ecma-international.org/ecma-262/5.1/#sec-9.2 /// </summary> /// <param name="o"></param> /// <returns></returns> public static bool ToBoolean(JsValue o) { if (o.IsObject()) { return true; } if (o == Undefined.Instance || o == Null.Instance) { return false; } if (o.IsBoolean()) { return o.AsBoolean(); } if (o.IsNumber()) { var n = o.AsNumber(); if (n.Equals(0) || double.IsNaN(n)) { return false; } else { return true; } } if (o.IsString()) { var s = o.AsString(); if (String.IsNullOrEmpty(s)) { return false; } else { return true; } } return true; }
public async void sendAppMessage(ExpandoObject data, object functionAck, object functionNack) { await sendAppMessage(data); System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue> _func = functionAck as System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue>; Jint.Native.JsValue A = new JsValue(1); Jint.Native.JsValue[] B = new Jint.Native.JsValue[1]; Jint.Native.Json.JsonParser _jsp = new Jint.Native.Json.JsonParser(JintEngine); String JSON = "null"; Jint.Native.JsValue _eValue = _jsp.Parse(JSON); B[0] = _eValue; Jint.Native.JsValue C = _func.Invoke(A, B); }
public PropertyDescriptor(JsValue? value, bool? writable, bool? enumerable, bool? configurable) { Value = value; if (writable.HasValue) { Writable = new JsValue(writable.Value); } if (enumerable.HasValue) { Enumerable = new JsValue(enumerable.Value); } if (configurable.HasValue) { Configurable = new JsValue(configurable.Value); } }
public RavenJObject ToRavenJObject(JsValue jsObject, string propertyKey = null) { var rjo = new RavenJObject(); foreach (var property in jsObject.AsObject().Properties) { if (property.Key == Constants.ReduceKeyFieldName || property.Key == Constants.DocumentIdFieldName) continue; var value = property.Value.Value; if (!value.HasValue) continue; if (value.Value.IsRegExp()) continue; rjo[property.Key] = ToRavenJToken(value.Value, CreatePropertyKey(property.Key, propertyKey)); } return rjo; }
public bool CreateAlias(string AliasName, string Cost, int CooldownSeconds, string Permissions, JsValue func) { try { JistAliasModule.JScriptAliasCommand jAlias = new JistAliasModule.JScriptAliasCommand() { CommandAlias = AliasName as string, CooldownSeconds = Convert.ToInt32(CooldownSeconds), Cost = Cost as string, Permissions = Permissions as string, func = (Jint.Native.JsValue)func }; aliasEngine.CreateAlias(jAlias); } catch (Exception ex) { Jist.ScriptLog.ErrorFormat("aliascmd", "CreateAlias failed: " + ex.Message); return false; } return true; }
public async Task AppMessage(Dictionary <int, object> Content) { try { if (!_Pebble.EventListeners.ContainsKey("appmessage")) { return; } var jsfunction = _Pebble.EventListeners["appmessage"]; System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue> _func = jsfunction as System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue>; String JSON = ""; foreach (var item in Content) { var keys = from entry in _ParentItem.AppKeys where entry.Value == item.Key select entry.Key; if (keys.Count() == 1) { if (JSON.Length > 0) { JSON += ", "; } JSON += String.Format("\"{0}\": ", keys.FirstOrDefault()); if (item.Value.GetType() == typeof(string)) { JSON += String.Format("\"{0}\"", item.Value); } if (item.Value.GetType() == typeof(int)) { JSON += String.Format("{0}", item.Value); } if (item.Value.GetType() == typeof(bool)) { JSON += String.Format("{0}", (bool)item.Value ? 1 : 0); } } } Jint.Native.JsValue A = new JsValue(1); Jint.Native.JsValue[] B = new Jint.Native.JsValue[1]; Jint.Native.Json.JsonParser _jsp = new Jint.Native.Json.JsonParser(_JintEngine); B[0] = _jsp.Parse(String.Format("{{\"payload\": {{ {0} }} }}", JSON)); Jint.Native.JsValue C = _func.Invoke(A, B); } catch (Jint.Runtime.JavaScriptException exp) { String Exception = String.Format("{0}" + Environment.NewLine + "Line: {1}" + Environment.NewLine + "Source: {2}", exp.Message, exp.LineNumber, _JavascriptLines[exp.LineNumber - 1]); throw new System.Exception(Exception); } catch (Exception exp) { throw exp; } }
public async void send(object data) { WebResponse _response; try { System.Diagnostics.Debug.WriteLine(String.Format("XMLHttpRequest.send data={0}", data == null ? "null" : data.ToString())); _httpWebRequest.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"; //_httpWebRequest.Accept = "text/html, application/json"; //Accept-Encoding: gzip, deflate //Accept-Language: nl-NL, nl; q=0.5 //Cache-Control: no-cache //Connection: Keep-Alive //Host: nominatim.openstreetmap.org //User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586 _response = await _httpWebRequest.GetResponseAsync(); Stream _stream = _response.GetResponseStream(); StreamReader _tr = new StreamReader(_stream); String Response = _tr.ReadToEnd(); System.Diagnostics.Debug.WriteLine(String.Format("XMLHttpRequest.send response={0}", Response)); _readyState = 4; _status = 200; _responseText = Response; if (onload != null) { var jsfunction = onload; System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue> _func = jsfunction as System.Func <Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue>; String JSON = String.Format("{{\"responseText\":\"{0}\" }}", JSONEncode(Response)); Jint.Native.Json.JsonParser _jsp = new Jint.Native.Json.JsonParser(new Jint.Engine()); Jint.Native.JsValue _eValue = _jsp.Parse(JSON); Jint.Native.JsValue A = _eValue; Jint.Native.JsValue[] B = new JsValue[1]; B[0] = new Jint.Native.JsValue(Response); Jint.Native.JsValue C = _func.Invoke(A, B); } } catch (Jint.Runtime.JavaScriptException exc) { System.Diagnostics.Debug.WriteLine("JavaScriptException " + exc.Message + exc.LineNumber); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Exception " + e.Message); } finally { //_response.Close; } }