ColumnWriterDetails GetDecimalColumnWriterDetails(bool isNullable, uint columnId, PropertyInfo propertyInfo, Func <object, decimal?> valueGetter, SerializationPropertyConfiguration propertyConfiguration) { var precision = propertyConfiguration?.DecimalPrecision ?? _defaultDecimalPrecision; var scale = propertyConfiguration?.DecimalScale ?? _defaultDecimalScale; var state = new List <decimal?>(); var columnWriter = new DecimalWriter(isNullable, _shouldAlignNumericValues, precision, scale, _bufferFactory, columnId); 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 = Protocol.ColumnTypeKind.Decimal, Precision = (uint)precision, Scale = (uint)scale } }); }
private ColumnWriterDetails GetDecimalColumnWriterDetails(bool isNullable, uint columnId, PropertyInfo propertyInfo, Func <object, decimal?> valueGetter) { //TODO add two options to configure Precision and Scale, via an attribute on the property, and via a fluent configuration source var precision = _defaultDecimalPrecision; var scale = _defaultDecimalScale; var state = new List <decimal?>(); var columnWriter = new DecimalWriter(isNullable, _shouldAlignNumericValues, precision, scale, _bufferFactory, columnId); 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 ColumnType { Kind = ColumnTypeKind.Decimal, Precision = (uint)precision, Scale = (uint)scale } }); }