AddEmbeddedCollection() 공개 메소드

public AddEmbeddedCollection ( string name, IEnumerable objects ) : HALResponse
name string
objects IEnumerable
리턴 HALResponse
예제 #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);
        }
예제 #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);
        }