Halcyon.HAL.Attributes.HALAttributeConverter.Convert C# (CSharp) Method

Convert() public method

public Convert ( object model ) : HALResponse
model object
return HALResponse
        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;
        }

Usage Example

Esempio n. 1
0
        public void Link_Constructed_From_Attribute()
        {
            var model = new PersonModelWithAttributes();
            var converter = new HALAttributeConverter();

            var halResponse = converter.Convert(model);

            Assert.True(halResponse.HasSelfLink());
        }
All Usage Examples Of Halcyon.HAL.Attributes.HALAttributeConverter::Convert
HALAttributeConverter