예제 #1
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);
 }
예제 #2
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);
 }
예제 #3
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);
 }
예제 #4
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);
 }