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 conditional reinterpret cast to a byte sequence. /// </summary> /// <param name="canConvert"></param> /// <param name="asBytes">A ReadOnlySpan<byte> view of a value.</param> public ScalarBuilder With( Func <TParams, bool> canConvert, AsSpan <TParams, byte> asBytes) { canConvert.ThrowIfNull(nameof(canConvert)); asBytes.ThrowIfNull(nameof(asBytes)); _builder.Converters.Add(ValueBinder.Converter.Blob(canConvert, asBytes)); return(this); }
/// <summary> /// Defines a conditional reinterpret cast to a UTF-16 string. /// </summary> /// <param name="canConvert"></param> /// <param name="asText">A ReadOnlySpan<char> view of a value.</param> public ScalarBuilder With( Func <TParams, bool> canConvert, AsSpan <TParams, char> asText) { canConvert.ThrowIfNull(nameof(canConvert)); asText.ThrowIfNull(nameof(asText)); _builder.Converters.Add(ValueBinder.Converter.Utf16Text(canConvert, asText)); return(this); }
/// <summary> /// Defines a reinterpret cast from a member value to a byte sequence. /// </summary> /// <param name="propertyOrField"></param> /// <param name="asBytes">A ReadOnlySpan<byte> view of a value.</param> public Builder With <TField>( Expression <Func <TParams, TField> > propertyOrField, AsSpan <TField, byte> asBytes) { propertyOrField.ThrowIfNull(nameof(propertyOrField)); asBytes.ThrowIfNull(nameof(asBytes)); GetOrAdd(propertyOrField) .Converters .Add(ValueBinder.Converter.Blob(asBytes)); return(this); }
/// <summary> /// Defines a reinterpret cast from a member value to a UTF-16 string. /// </summary> /// <param name="propertyOrField"></param> /// <param name="asText">A ReadOnlySpan<char> view of a value.</param> public Builder With <TField>( Expression <Func <TParams, TField> > propertyOrField, AsSpan <TField, char> asText) { propertyOrField.ThrowIfNull(nameof(propertyOrField)); asText.ThrowIfNull(nameof(asText)); GetOrAdd(propertyOrField) .Converters .Add(ValueBinder.Converter.Utf16Text(asText)); return(this); }
/// <summary> /// Get row by index. /// </summary> /// <returns>The span of the row.</returns> public Span <float> this[int i] => AsSpan.Slice(i * 4, 3);
/// <summary> /// Defines a reinterpret cast to a byte sequence. /// </summary> /// <param name="asBytes">A ReadOnlySpan<byte> view of a value.</param> public ScalarBuilder With(AsSpan <TParams, byte> asBytes) { asBytes.ThrowIfNull(nameof(asBytes)); _builder.Converters.Add(ValueBinder.Converter.Blob(asBytes)); return(this); }
/// <summary> /// Defines a reinterpret cast to a UTF-16 string. /// </summary> /// <param name="asText">A ReadOnlySpan<char> view of a value.</param> public ScalarBuilder With(AsSpan <TParams, char> asText) { asText.ThrowIfNull(nameof(asText)); _builder.Converters.Add(ValueBinder.Converter.Utf16Text(asText)); return(this); }