ColumnWriterDetails GetColumnWriterDetails <T>(IColumnWriter <T> columnWriter, PropertyInfo propertyInfo, Func <object, T> valueGetter, Protocol.ColumnTypeKind columnKind) { var state = new List <T>(); return(new ColumnWriterDetails { PropertyName = propertyInfo.Name, ColumnWriter = columnWriter, AddValueToState = classInstance => { var value = valueGetter(classInstance); state.Add(value); }, WriteValuesFromState = () => { columnWriter.AddBlock(state); state.Clear(); }, ColumnType = new Protocol.ColumnType { Kind = columnKind } }); }
Action <object> GetReadAndSetterForColumn(PropertyInfo propertyInfo, Stripes.StripeStreamReaderCollection stripeStreams, uint columnId, Protocol.ColumnTypeKind columnType) { switch (columnType) { case Protocol.ColumnTypeKind.Long: case Protocol.ColumnTypeKind.Int: case Protocol.ColumnTypeKind.Short: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.LongReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.Byte: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.ByteReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.Boolean: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.BooleanReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.Float: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.FloatReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.Double: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.DoubleReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.Binary: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.BinaryReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.Decimal: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.DecimalReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.Timestamp: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.TimestampReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.Date: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.DateReader(stripeStreams, columnId).Read())); case Protocol.ColumnTypeKind.String: return(GetValueSetterEnumerable(propertyInfo, new ColumnTypes.StringReader(stripeStreams, columnId).Read())); default: throw new NotImplementedException($"Column type {columnType} is not supported"); } }