public static Type SafeGetType(object o) { var jsObject = o.As <JsObject>(); if (jsObject.member("GetType") != null) { return(jsObject.member("GetType").invoke().As <Type>()); } var type = Jsni._typeof(jsObject); if (type == "boolean") { return(typeof(bool)); } if (type == "number") { return(typeof(Number)); } throw new Exception("Unable to determine type of: " + o); }
public static string SafeToString(object o) { return(o == null ? "" : Jsni._typeof(o.As <JsObject>()) == "boolean" ? o.As <JsObject>().toString().As <string>() : o.ToString()); }