public Converter( Sqlite.DataType dataType, bool utf8Text, Func <TField, bool>?canConvert, Func <TField, int>?length, Func <TField, long>?toInteger, Func <TField, double>?toFloat, ToSpan <TField, char>?toUtf16Text, AsSpan <TField, char>?asUtf16Text, ToSpan <TField, byte>?toUtf8Text, AsSpan <TField, byte>?asUtf8Text, ToSpan <TField, byte>?toBlob, AsSpan <TField, byte>?asBlob) { DataType = dataType; Utf8Text = utf8Text; _canConvert = canConvert; Length = length; ToInteger = toInteger; ToFloat = toFloat; ToUtf16Text = toUtf16Text; AsUtf16Text = asUtf16Text; ToUtf8Text = toUtf8Text; AsUtf8Text = asUtf8Text; ToBlob = toBlob; AsBlob = asBlob; }
/// <summary> /// Defines a conversion to a UTF-16 string. /// </summary> /// <param name="toText">Serializes a value to a destination Span<char></param> /// <param name="length">Length of the Span<char> that a value will be serialized to.</param> public ScalarBuilder With( ToSpan <TParams, char> toText, Func <TParams, int> length) { toText.ThrowIfNull(nameof(toText)); length.ThrowIfNull(nameof(length)); _builder.Converters.Add(ValueBinder.Converter.Utf16Text(toText, length)); return(this); }
/// <summary> /// Defines a conversion to a byte sequence. /// </summary> /// <param name="toBytes">Serializes a value to a destination Span<byte></param> /// <param name="length">Length of the Span<byte> that a value will be serialized to.</param> public ScalarBuilder With( ToSpan <TParams, byte> toBytes, Func <TParams, int> length) { toBytes.ThrowIfNull(nameof(toBytes)); length.ThrowIfNull(nameof(length)); _builder.Converters.Add(ValueBinder.Converter.Blob(toBytes, length)); return(this); }
/// <summary> /// Defines a conversion from a member value to a byte sequence. /// </summary> /// <param name="propertyOrField"></param> /// <param name="toBytes">Serializes a value to a destination Span<byte></param> /// <param name="length">Length of the Span<byte> that a value will be serialized to.</param> public Builder With <TField>( Expression <Func <TParams, TField> > propertyOrField, ToSpan <TField, byte> toBytes, Func <TField, int> length) { propertyOrField.ThrowIfNull(nameof(propertyOrField)); toBytes.ThrowIfNull(nameof(toBytes)); length.ThrowIfNull(nameof(length)); GetOrAdd(propertyOrField) .Converters .Add(ValueBinder.Converter.Blob(toBytes, length)); return(this); }
/// <summary> /// Defines a conversion from a member value to a UTF-16 string. /// </summary> /// <param name="propertyOrField"></param> /// <param name="toText">Serializes a value to a destination Span<char></param> /// <param name="length">Length of the Span<char> that a value will be serialized to.</param> public Builder With <TField>( Expression <Func <TParams, TField> > propertyOrField, ToSpan <TField, char> toText, Func <TField, int> length) { propertyOrField.ThrowIfNull(nameof(propertyOrField)); toText.ThrowIfNull(nameof(toText)); length.ThrowIfNull(nameof(length)); GetOrAdd(propertyOrField) .Converters .Add(ValueBinder.Converter.Utf16Text(toText, length)); return(this); }