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

CanConvert() public method

public CanConvert ( Type type ) : bool
type System.Type
return bool
        public bool CanConvert(Type type)
        {
            if(type == null || type == typeof(HALResponse)) {
                return false;
            }

            // Is it worth caching this check?
            return type.GetTypeInfo().GetCustomAttributes().Any(x => x is HalModelAttribute);
        }

Usage Example

        public void Should_not_be_able_to_convert_non_attribute_marked_model()
        {
            var model = new object();
            var converter = new HALAttributeConverter();

            Assert.False(converter.CanConvert(model.GetType()));
        }
All Usage Examples Of Halcyon.HAL.Attributes.HALAttributeConverter::CanConvert
HALAttributeConverter