Example #1
0
        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);
        }
Example #2
0
 public static string SafeToString(object o)
 {
     return(o == null ? "" : Jsni._typeof(o.As <JsObject>()) == "boolean" ? o.As <JsObject>().toString().As <string>() : o.ToString());
 }