示例#1
0
        public HALResponse Convert(object model)
        {
            if (!this.CanConvert(model?.GetType()))
            {
                throw new InvalidOperationException();
            }

            var resolver  = new HALAttributeResolver();
            var halConfig = resolver.GetConfig(model);

            var response = new HALResponse(model, halConfig);

            resolver.AddEmbeddedResources(response, model, halConfig);
            return(response);
        }
        public HALResponse Convert(object model)
        {
            if(!this.CanConvert(model?.GetType())) {
                throw new InvalidOperationException();
            }

            var resolver = new HALAttributeResolver();

            var halConfig = resolver.GetConfig(model);

            var response = new HALResponse(model, halConfig);
            response.AddLinks(resolver.GetLinks(model));
            response.AddEmbeddedCollections(resolver.GetEmbeddedCollections(model, halConfig));

            return response;
        }