System.Type._GetTypeFromInstance C# (CSharp) Method

_GetTypeFromInstance() static private method

static private _GetTypeFromInstance ( JsObject instance ) : Type
instance JsObject
return Type
        internal static Type _GetTypeFromInstance(JsObject instance)
        {
            var typeFunction = instance["$type"].As<JsTypeFunction>();
            if (typeFunction == null)
            {
                var typeString = Jsni._typeof(instance);
                if (typeString == "string".As<JsString>())
                {
                    return typeof(string);
                }
                if (typeString == "number".As<JsString>())
                {
                    return typeof(Number);
                }
                if (typeString == "object".As<JsString>())
                {
                    return typeof(object);
                }
                if (typeString == "function".As<JsString>())
                {
                    return typeof(Delegate);
                }
                else
                {
                    throw new Exception();
                }
            }
            else
            {
                return _GetTypeFromTypeFunc(typeFunction);
            }
        }

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// Retrieves the type associated with an object instance.
 /// </summary>
 /// <returns>The type of the object.</returns>
 public Type GetType()
 {
     return(Type._GetTypeFromInstance(this.As <JsObject>()));
 }