in Clients/CrossBrowser/Xamarin.CrossBrowser.Mac/ScriptContext.cs [85:131]
internal JSValue ToJSValue (object o)
{
if (o == null)
return JSValue.Null (underlyingContext);
if (o is JSValue)
return (JSValue)o;
if (o is WrappedObject)
return ((WrappedObject)o).UnderlyingJSValue;
if (o is ScriptAction)
return ((ScriptAction)o).ToJSValue (underlyingContext);
if (o is ScriptFunc)
return ((ScriptFunc)o).ToJSValue (underlyingContext);
if (o is Action)
return ((Action)o).ToJSValue (underlyingContext);
switch (Convert.GetTypeCode (o)) {
case TypeCode.Boolean:
return JSValue.From ((bool)o, underlyingContext);
case TypeCode.SByte:
return JSValue.From ((int)(sbyte)o, underlyingContext);
case TypeCode.Byte:
return JSValue.From ((uint)(byte)o, underlyingContext);
case TypeCode.Int16:
return JSValue.From ((int)(short)o, underlyingContext);
case TypeCode.UInt16:
return JSValue.From ((uint)(ushort)o, underlyingContext);
case TypeCode.Int32:
return JSValue.From ((int)o, underlyingContext);
case TypeCode.UInt32:
return JSValue.From ((uint)o, underlyingContext);
case TypeCode.Single:
return JSValue.From ((double)(float)o, underlyingContext);
case TypeCode.Double:
return JSValue.From ((double)o, underlyingContext);
case TypeCode.String:
return JSValue.From ((string)o, underlyingContext);
case TypeCode.Char:
return JSValue.From (o.ToString (), underlyingContext);
}
throw new ArgumentException ("cannot convert type '" + o.GetType () + "' to JSValue");
}