Пример #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 conversion to a UTF-16 string.
 /// </summary>
 /// <param name="toText">Serializes a value to a destination Span&lt;char&gt;</param>
 /// <param name="length">Length of the Span&lt;char&gt; 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);
 }
Пример #3
0
 /// <summary>
 /// Defines a conversion to a byte sequence.
 /// </summary>
 /// <param name="toBytes">Serializes a value to a destination Span&lt;byte&gt;</param>
 /// <param name="length">Length of the Span&lt;byte&gt; 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);
 }
Пример #4
0
 /// <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&lt;byte&gt;</param>
 /// <param name="length">Length of the Span&lt;byte&gt; 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);
 }
Пример #5
0
 /// <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&lt;char&gt;</param>
 /// <param name="length">Length of the Span&lt;char&gt; 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);
 }