AddEmbeddedCollection() public method

public AddEmbeddedCollection ( string name, IEnumerable objects ) : HALResponse
name string
objects IEnumerable
return HALResponse
Beispiel #1
0
        public static HALResponse AddEmbeddedCollections(this HALResponse response, IEnumerable <KeyValuePair <string, IEnumerable <HALResponse> > > embeddedCollections)
        {
            foreach (var embeddedCollection in embeddedCollections)
            {
                response.AddEmbeddedCollection(embeddedCollection.Key, embeddedCollection.Value);
            }

            return(response);
        }
Beispiel #2
0
        public static HALResponse AddEmbeddedCollection <T>(this HALResponse hyperMedia, string collectionName, IEnumerable <T> model, IEnumerable <Link> links = null)
        {
            if (links == null)
            {
                links = Enumerable.Empty <Link>();
            }

            var embedded = model
                           .Select(m => new HALResponse(m, hyperMedia.Config).AddLinks(links))
                           .ToArray();

            hyperMedia.AddEmbeddedCollection(collectionName, embedded);

            return(hyperMedia);
        }