private static object Deserialize(Tlv value, Type type) { if (type is null || value is null) { throw new ArgumentNullException("Provide an item and tlv"); } var properties = type.GetProperties().Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(TlvPropertyAttribute))); var item = Activator.CreateInstance(type); foreach (var property in properties) { SetValue(property, ref item, value); } return(item); }