/// <summary> /// Makes a mapping of value from the script type to a .net type /// added by chuan.yin in 2017/4/27 /// </summary> /// <param name="value">The source value</param> /// <returns>The mapped value</returns> private object ConvertJsObjectToNetObject(JsValue value) { JsValueType valueType = value.ValueType; JsValue processedValue; object result; switch (valueType) { case JsValueType.Null: result = null; break; case JsValueType.Undefined: result = Undefined.Value; break; case JsValueType.Boolean: processedValue = value.ConvertToBoolean(); result = processedValue.ToBoolean(); break; case JsValueType.Number: processedValue = value.ConvertToNumber(); result = NumericHelpers.CastDoubleValueToCorrectType(processedValue.ToDouble()); break; case JsValueType.String: processedValue = value.ConvertToString(); result = processedValue.ToString(); break; case JsValueType.Object: result = MapToNetObject(value); break; case JsValueType.Function: case JsValueType.Error: case JsValueType.Array: result = ToArray(value); break; case JsValueType.Symbol: case JsValueType.ArrayBuffer: case JsValueType.TypedArray: case JsValueType.DataView: result = ToObject(value); break; default: throw new ArgumentOutOfRangeException(); } return(result); }
public void SetUnderline(JsValue value) { if (value.IsString()) { Font.Underline = _underline.FromString(value.AsString(), FontUnderlineType.None); } else { Font.Underline = value.ConvertToBoolean().GetValueOrDefault() ? FontUnderlineType.Single : FontUnderlineType.None; } }
public override void SetValue(JsValue value) { ((CheckBox)Control).Checked = value.ConvertToBoolean().GetValueOrDefault(); }