Пример #1
0
        public static Javascript.Array ToArray(IList <string> list, Javascript.Scope scope)
        {
            var array = new Javascript.Array();

            foreach (var s in list)
            {
                array.List.Add(new Javascript.String(s));
            }
            return(array);
        }
Пример #2
0
        public static Constant JsonToValue(object value, Scope scope)
        {
            if (value is Dictionary <string, object> dict)
            {
                return(JsonToObject(dict, scope));
            }
            else if (value is List <object> list)
            {
                var array = new Javascript.Array();

                for (int i = 0; i < list.Count; i++)
                {
                    array.List.Add(JsonToValue(list[i], scope));
                }

                return(array);
            }
            else if (value is string s)
            {
                return(new Javascript.String(s));
            }
            else if (value is double d)
            {
                return(new Javascript.Number(d));
            }
            else if (value is long l)
            {
                return(new Javascript.Number(l));
            }
            else if (value is int i)
            {
                return(new Javascript.Number(i));
            }
            else if (value is bool b)
            {
                return(new Javascript.Boolean(b));
            }

            return(Static.Undefined);
        }