Esempio n. 1
0
        public override Constant GetProperty(Constant key, Scope scope)
        {
            if (key is Number n)
            {
                return(Get((int)n.Value));
            }

            var keyString = key.ToString();

            int index;

            if (int.TryParse(keyString, out index))
            {
                return(Get(index));
            }

            if (keyString == "length")
            {
                return(new Number(List.Count));
            }

            if (ArrayObject == null)
            {
                ArrayObject = Tool.Construct("Array", scope);
            }
            return(ArrayObject.Get(keyString));
        }
Esempio n. 2
0
        public static Dictionary <string, object> ObjectToJson(Javascript.Object obj, Scope scope)
        {
            var json = new Dictionary <string, object>();

            foreach (var key in obj.GetKeys())
            {
                json[key] = ValueToJson(obj.Get(key), scope);
            }
            return(json);
        }
Esempio n. 3
0
        public Constant Get(string name)
        {
            Constant value = null;

            if (Properties.TryGetValue(name, ref value))
            {
                return(value);
            }

            if (__proto__ != null)
            {
                return(__proto__.Get(name));
            }

            return(Static.Undefined);
        }
Esempio n. 4
0
 public static bool IsType(Javascript.Object obj, Javascript.Object prototype)
 {
     return(obj.__proto__ == prototype.Get <Javascript.Object>("prototype"));
 }