Пример #1
0
 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;
 }
Пример #2
0
 /// <summary>
 /// Defines a conditional reinterpret cast to a byte sequence.
 /// </summary>
 /// <param name="canConvert"></param>
 /// <param name="asBytes">A ReadOnlySpan&lt;byte&gt; 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);
 }
Пример #3
0
 /// <summary>
 /// Defines a conditional reinterpret cast to a UTF-16 string.
 /// </summary>
 /// <param name="canConvert"></param>
 /// <param name="asText">A ReadOnlySpan&lt;char&gt; 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);
 }
Пример #4
0
 /// <summary>
 /// Defines a reinterpret cast from a member value to a byte sequence.
 /// </summary>
 /// <param name="propertyOrField"></param>
 /// <param name="asBytes">A ReadOnlySpan&lt;byte&gt; 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);
 }
Пример #5
0
 /// <summary>
 /// Defines a reinterpret cast from a member value to a UTF-16 string.
 /// </summary>
 /// <param name="propertyOrField"></param>
 /// <param name="asText">A ReadOnlySpan&lt;char&gt; 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);
 }
Пример #6
0
 /// <summary>
 /// Get row by index.
 /// </summary>
 /// <returns>The span of the row.</returns>
 public              Span <float> this[int i] => AsSpan.Slice(i * 4, 3);
Пример #7
0
 /// <summary>
 /// Defines a reinterpret cast to a byte sequence.
 /// </summary>
 /// <param name="asBytes">A ReadOnlySpan&lt;byte&gt; 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);
 }
Пример #8
0
 /// <summary>
 /// Defines a reinterpret cast to a UTF-16 string.
 /// </summary>
 /// <param name="asText">A ReadOnlySpan&lt;char&gt; 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);
 }