/// <summary> /// Adds a <see cref="Link" /> object to the <see cref="LinkedResource" /> object. /// </summary> /// <param name="resource">Current <see cref="LinkedResource" /> object.</param> /// <param name="link"><see cref="Link" /> object to add.</param> /// <returns>Returns the <see cref="LinkedResource" /> object containing the <see cref="Link" /> object.</returns> public static LinkedResource AddLink(this LinkedResource resource, Link link) { if (link == null) { return resource; } resource.Links.Add(link); return resource; }
/// <summary> /// Gets the given number of products. /// </summary> /// <param name="count">Number of items to set.</param> /// <returns>Returns the given number of products.</returns> public static Products GetProducts(int count) { var items = new List<Product>(); for (var i = 0; i < count; i++) { var item = GetProduct(i + 1); items.Add(item); } var products = new Products(items); var link = new Link() { Rel = "self", Href = "/products" }; products.AddLink(link); return products; }