Ejemplo n.º 1
0
        public static Promise all(IIterable promises)
        {
            if (promises == null)
            {
                return(new Promise(fromException(new JSException(new TypeError("Invalid argruments for Promise.all(...)")))));
            }

            return(new Promise(whenAll(promises.AsEnumerable().Select(convertToTask).ToArray()).ContinueWith(x => new Array(x.Result as IEnumerable) as JSValue)));
        }
Ejemplo n.º 2
0
        public static Promise race(IIterable promises)
        {
            if (promises == null)
            {
                return(new Promise(fromException(new JSException(new TypeError("Invalid argruments for Promise.race(...)")))));
            }

            return(new Promise(whenAny(promises.AsEnumerable().Select(convertToTask).ToArray()).ContinueWith(x => x.Result.Result)));
        }
Ejemplo n.º 3
0
        public Set(IIterable iterable)
            : this()
        {
            if (iterable == null)
            {
                return;
            }

            foreach (var value in iterable.AsEnumerable())
            {
                _storage.Add(value.Value);
            }
        }
Ejemplo n.º 4
0
Archivo: List.cs Proyecto: slagusev/api
        /// <summary>
        /// Copy ctor
        /// </summary>
        public List(IIterable <T> source)
        {
            var colSource = source as Java.Util.ICollection <T>;

            if (colSource != null)
            {
                list = new ArrayList <T>(colSource);
            }
            else
            {
                list = new ArrayList <T>();
                foreach (var item in source.AsEnumerable())
                {
                    list.Add(item);
                }
            }
        }
Ejemplo n.º 5
0
        public Map(IIterable iterable)
            : this()
        {
            if (iterable == null)
            {
                return;
            }

            foreach (var item in iterable.AsEnumerable())
            {
                if (item._valueType < JSValueType.Object)
                {
                    ExceptionHelper.ThrowTypeError($"Iterator value {item} is not an entry object");
                }

                var value = item["1"];
                _storage[item["0"].Value] = value.Value as JSValue ?? value;
            }
        }