private static void testLinkedEntity <T>(ILinkedEntity <T> entity) { Assert.IsNotNull(entity); Assert.AreNotEqual(0, entity.Id); Assert.IsNotNull(entity.Href); Assert.IsNotNull(entity.Name); }
/// <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<TOut[]>.</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)); }
/// <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<T>.</returns> public T Load <T>(ILinkedEntity <T> entity, params string[] parameters) where T : class, ICrestResource <T> { return(LoadAsync(entity, parameters).Result); }
/// <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<T>.</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)); }
/// <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); }
/// <summary> /// Queries the options asynchronous. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity">The entity.</param> /// <returns>Task<CrestOptions>.</returns> public Task <CrestOptions> QueryOptionsAsync <T>(ILinkedEntity <T> entity) { return(optionsAsync(entity.Href.Uri)); }
/// <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); }
/// <summary> /// Queries the head asynchronous. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity">The entity.</param> /// <returns>Task<WebHeaderCollection>.</returns> public Task <WebHeaderCollection> QueryHeadAsync <T>(ILinkedEntity <T> entity) { return(headAsync(entity.Href.Uri)); }
/// <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<T>.</returns> public T Load <T>(ILinkedEntity <T> entity) where T : class, ICrestResource <T> { return(LoadAsync(entity).Result); }
/// <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<T>.</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))); }