Esempio n. 1
0
 private static void testLinkedEntity <T>(ILinkedEntity <T> entity)
 {
     Assert.IsNotNull(entity);
     Assert.AreNotEqual(0, entity.Id);
     Assert.IsNotNull(entity.Href);
     Assert.IsNotNull(entity.Name);
 }
Esempio n. 2
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));
        }
Esempio n. 3
0
 /// <summary>
 /// Loads a ILinkedEntity
 /// </summary>
 /// <typeparam name="T">The resource type, usually inferred from the parameter</typeparam>
 /// <param name="entity">The items that should be loaded</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>Task&lt;T&gt;.</returns>
 public T Load <T>(ILinkedEntity <T> entity, params string[] parameters) where T : class, ICrestResource <T>
 {
     return(LoadAsync(entity, parameters).Result);
 }
Esempio n. 4
0
 /// <summary>
 /// Loads a ILinkedEntity async
 /// </summary>
 /// <typeparam name="T">The resource type, usually inferred from the parameter</typeparam>
 /// <param name="entity">The items that should be loaded</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>Task&lt;T&gt;.</returns>
 public Task <T> LoadAsync <T>(ILinkedEntity <T> entity, params string[] parameters)
     where T : class, ICrestResource <T>
 {
     return(entity == null?Task.FromResult(default(T)) : LoadAsync(entity.Href, parameters));
 }
Esempio n. 5
0
 /// <summary>
 /// Queries the options.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="entity">The entity.</param>
 /// <returns>CrestOptions.</returns>
 public CrestOptions QueryOptions <T>(ILinkedEntity <T> entity)
 {
     return(QueryOptionsAsync(entity).Result);
 }
Esempio n. 6
0
 /// <summary>
 /// Queries the options asynchronous.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="entity">The entity.</param>
 /// <returns>Task&lt;CrestOptions&gt;.</returns>
 public Task <CrestOptions> QueryOptionsAsync <T>(ILinkedEntity <T> entity)
 {
     return(optionsAsync(entity.Href.Uri));
 }
Esempio n. 7
0
 /// <summary>
 /// Queries the head.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="entity">The entity.</param>
 /// <returns>WebHeaderCollection.</returns>
 public WebHeaderCollection QueryHead <T>(ILinkedEntity <T> entity)
 {
     return(QueryHeadAsync(entity).Result);
 }
Esempio n. 8
0
 /// <summary>
 /// Queries the head asynchronous.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="entity">The entity.</param>
 /// <returns>Task&lt;WebHeaderCollection&gt;.</returns>
 public Task <WebHeaderCollection> QueryHeadAsync <T>(ILinkedEntity <T> entity)
 {
     return(headAsync(entity.Href.Uri));
 }
Esempio n. 9
0
 /// <summary>
 ///     Loads a ILinkedEntity
 /// </summary>
 /// <typeparam name="T">The resource type, usually inferred from the parameter</typeparam>
 /// <param name="entity">The items that should be loaded</param>
 /// <returns>Task&lt;T&gt;.</returns>
 public T Load <T>(ILinkedEntity <T> entity) where T : class, ICrestResource <T>
 {
     return(LoadAsync(entity).Result);
 }
Esempio n. 10
0
 /// <summary>
 ///     Loads a ILinkedEntity async
 /// </summary>
 /// <typeparam name="T">The resource type, usually inferred from the parameter</typeparam>
 /// <param name="entity">The items that should be loaded</param>
 /// <returns>Task&lt;T&gt;.</returns>
 public Task <T> LoadAsync <T>(ILinkedEntity <T> entity) where T : class, ICrestResource <T>
 {
     return(entity == null?Task.FromResult(default(T)) : requestAsync <T>(new Uri(entity.Href.Uri)));
 }