/// <inheritdoc/> public T Read(ref MessagePackReader reader, Schema schema, bool keyOnly = false) { var columns = schema.Columns; var count = keyOnly ? schema.KeyColumnCount : columns.Count; var res = Activator.CreateInstance <T>(); var type = typeof(T); for (var index = 0; index < count; index++) { if (reader.TryReadNoValue()) { continue; } var col = columns[index]; var prop = GetPropertyIgnoreCase(type, col.Name); if (prop != null) { var value = reader.ReadObject(col.Type); prop.SetValue(res, value); } else { reader.Skip(); } } return((T)(object)res); }
/// <inheritdoc/> public T ReadValuePart(ref MessagePackReader reader, Schema schema, T key) { var columns = schema.Columns; var res = Activator.CreateInstance <T>(); var type = typeof(T); for (var i = 0; i < columns.Count; i++) { var col = columns[i]; var prop = GetPropertyIgnoreCase(type, col.Name); if (i < schema.KeyColumnCount) { if (prop != null) { prop.SetValue(res, prop.GetValue(key)); } } else { if (reader.TryReadNoValue()) { continue; } if (prop != null) { prop.SetValue(res, reader.ReadObject(col.Type)); } else { reader.Skip(); } } } return(res); }