Example #1
0
        /// <summary>
        /// Queries a collection of resources asynchronously.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public virtual Task <IEnumerable <TOut> > QueryAsync <TOut>(Func <T, IEnumerable <Href <TOut> > > objFunc, params string[] parameters)
            where TOut : class, ICrestResource <TOut>
        {
            IEnumerable <Href <TOut> > items = objFunc.Invoke(this as T);

            return(EveCrest.LoadAsync(items, parameters));
        }
Example #2
0
        /// <summary>
        ///     Queries a collection of resources asynchronously.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public virtual Task <IEnumerable <TOut> > QueryAsync <TOut>(Func <T, IEnumerable <ILinkedEntity <TOut> > > objFunc)
            where TOut : class, ICrestResource <TOut>
        {
            IEnumerable <ILinkedEntity <TOut> > items = objFunc.Invoke(this as T);

            return(EveCrest.LoadAsync(items));
        }
Example #3
0
        public async Task GetAllItems()
        {
            var alliances = await(await _crest.GetRootAsync()).QueryAsync(r => r.Alliances);
            await Task.WhenAll(alliances.Items.Select(a => _crest.LoadAsync(a)));

            //var list = alliances.Items.Select(alliance => _crest.Load(alliance)).ToList();

            //Assert.AreEqual(alliances.TotalCount, alliances.AllItems().Count());
        }
        /// <summary>
        ///     Queries a collection resource for a single item, async.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public async Task <TOut> QueryAsync <TOut>(Func <IEnumerable <TItem>, Href <TOut> > objFunc)
            where TOut : class, ICrestResource <TOut>
        {
            //var collection = this;
            //var list = collection.Items.ToList();
            //if (EveCrest.EnableAutomaticPaging) {
            //    while (collection.Next != null) {
            //        collection = await EveCrest.LoadAsync(collection.Next).ConfigureAwait(false);
            //        list.AddRange(collection.Items);
            //    }
            //}
            var item = objFunc.Invoke(this);

            return(await EveCrest.LoadAsync(item).ConfigureAwait(false));
        }
Example #5
0
        /// <summary>
        /// Gets all items in the collection as an asynchronous operation.
        /// </summary>
        /// <returns>Task&lt;IEnumerable&lt;TCollection&gt;&gt;.</returns>
        public async Task <IEnumerable <TCollection> > AllItemsAsync()
        {
            CollectionResource <T, TCollection> collection = this;
            List <TCollection> list = collection.Items.ToList();

            if (EveCrest.EnableAutomaticPaging)
            {
                while (collection.Next != null)
                {
                    collection = await EveCrest.LoadAsync(collection.Next).ConfigureAwait(false);

                    list.AddRange(collection.Items);
                }
            }
            return(list);
        }
        /// <summary>
        ///     Gets all items in the collection as an asynchronous operation.
        /// </summary>
        /// <returns>Task&lt;IEnumerable&lt;TCollection&gt;&gt;.</returns>
        public async Task <IEnumerable <TItem> > AllItemsAsync()
        {
            var collection = this;
            var list       = collection.Items.ToList();

            while (collection.Next != null)
            {
                if (collection.NextResource == null)
                {
                    collection.NextResource = await EveCrest.LoadAsync(collection.Next).ConfigureAwait(false);
                }
                collection = collection.NextResource;
                list.AddRange(collection.Items);
            }
            return(list);
        }
Example #7
0
        /// <summary>
        ///     Queries a collection resource for a single item, async.
        /// </summary>
        /// <typeparam name="TOut">The type of the t out.</typeparam>
        /// <param name="objFunc">The object function.</param>
        /// <returns>Task&lt;TOut[]&gt;.</returns>
        public async Task <TOut> QueryAsync <TOut>(Func <IEnumerable <TCollection>, ILinkedEntity <TOut> > objFunc)
            where TOut : class, ICrestResource <TOut>
        {
            CollectionResource <T, TCollection> collection = this;
            List <TCollection> list = collection.Items.ToList();

            if (EveCrest.EnableAutomaticPaging)
            {
                while (collection.Next != null)
                {
                    collection = await EveCrest.LoadAsync(collection.Next).ConfigureAwait(false);

                    list.AddRange(collection.Items);
                }
            }
            ILinkedEntity <TOut> item = objFunc.Invoke(list);

            return(await EveCrest.LoadAsync(item).ConfigureAwait(false));
        }
Example #8
0
 /// <summary>
 ///     Queries the resource asynchronously.
 /// </summary>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <param name="objFunc">The object function.</param>
 /// <returns>Task&lt;TOut&gt;.</returns>
 public Task <TOut> QueryAsync <TOut>(Func <T, ILinkedEntity <TOut> > objFunc)
     where TOut : class, ICrestResource <TOut>
 {
     return(EveCrest.LoadAsync(objFunc.Invoke(this as T)));
 }
Example #9
0
 /// <summary>
 /// Queries the resource asynchronously.
 /// </summary>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <param name="objFunc">The object function.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>Task&lt;TOut&gt;.</returns>
 public Task <TOut> QueryAsync <TOut>(Func <T, Href <TOut> > objFunc, params string[] parameters)
     where TOut : class, ICrestResource <TOut>
 {
     return(EveCrest.LoadAsync(objFunc.Invoke(this as T), parameters));
 }
Example #10
0
 /// <summary>
 /// Queries the asynchronous.
 /// </summary>
 /// <typeparam name="TOut">The type of the t out.</typeparam>
 /// <typeparam name="TParam">The type of the t parameter.</typeparam>
 /// <param name="objFunc">The object function.</param>
 /// <param name="param">The parameter.</param>
 /// <returns>Task&lt;TOut&gt;.</returns>
 public Task <TOut> QueryAsync <TOut, TParam>(Func <T, Href <TOut> > objFunc, LinkedEntity <TParam> param)
     where TOut : class, ICrestResource <TOut> where TParam : IQueryParameter <TParam>
 {
     return(EveCrest.LoadAsync(objFunc.Invoke(this as T), param));
 }