/// <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); }