Class SliceEncoderExtensions
Provides extension methods for SliceEncoder to encode dictionaries, results, and sequences.
public static class SliceEncoderExtensions
- Inheritance
-
SliceEncoderExtensions
- Inherited Members
Methods
EncodeDictionaryWithOptionalValueType<TKey, TValue>(ref SliceEncoder, IEnumerable<KeyValuePair<TKey, TValue>>, EncodeAction<TKey>, EncodeAction<TValue>)
Encodes a dictionary with an optional value type (T? in Slice).
public static void EncodeDictionaryWithOptionalValueType<TKey, TValue>(this ref SliceEncoder encoder, IEnumerable<KeyValuePair<TKey, TValue>> v, EncodeAction<TKey> keyEncodeAction, EncodeAction<TValue> valueEncodeAction) where TKey : notnull
Parameters
encoderSliceEncoderThe Slice encoder.
vIEnumerable<KeyValuePair<TKey, TValue>>The dictionary to encode.
keyEncodeActionEncodeAction<TKey>The encode action for the keys.
valueEncodeActionEncodeAction<TValue>The encode action for the non-null values.
Type Parameters
TKeyThe dictionary key type.
TValueThe dictionary value type.
EncodeDictionary<TKey, TValue>(ref SliceEncoder, IEnumerable<KeyValuePair<TKey, TValue>>, EncodeAction<TKey>, EncodeAction<TValue>)
Encodes a dictionary.
public static void EncodeDictionary<TKey, TValue>(this ref SliceEncoder encoder, IEnumerable<KeyValuePair<TKey, TValue>> v, EncodeAction<TKey> keyEncodeAction, EncodeAction<TValue> valueEncodeAction) where TKey : notnull
Parameters
encoderSliceEncoderThe Slice encoder.
vIEnumerable<KeyValuePair<TKey, TValue>>The dictionary to encode.
keyEncodeActionEncodeAction<TKey>The encode action for the keys.
valueEncodeActionEncodeAction<TValue>The encode action for the values.
Type Parameters
TKeyThe dictionary key type.
TValueThe dictionary value type.
EncodeResult<TSuccess, TFailure>(ref SliceEncoder, Result<TSuccess, TFailure>, EncodeAction<TSuccess>, EncodeAction<TFailure>)
Encodes a result.
public static void EncodeResult<TSuccess, TFailure>(this ref SliceEncoder encoder, Result<TSuccess, TFailure> v, EncodeAction<TSuccess> successEncodeAction, EncodeAction<TFailure> failureEncodeAction)
Parameters
encoderSliceEncoderThe Slice encoder.
vResult<TSuccess, TFailure>The result to encode.
successEncodeActionEncodeAction<TSuccess>The encode action for the success type.
failureEncodeActionEncodeAction<TFailure>The encode action for the failure type.
Type Parameters
TSuccessThe type of the success value.
TFailureThe type of the failure value.
EncodeSequenceOfOptionals<T>(ref SliceEncoder, IEnumerable<T>, EncodeAction<T>)
Encodes a sequence where the element type is an optional Slice type (T?).
public static void EncodeSequenceOfOptionals<T>(this ref SliceEncoder encoder, IEnumerable<T> v, EncodeAction<T> encodeAction)
Parameters
encoderSliceEncoderThe Slice encoder.
vIEnumerable<T>The sequence to encode.
encodeActionEncodeAction<T>The encode action for a non-null value.
Type Parameters
TThe nullable type of the sequence elements.
Remarks
This method always encodes a bit sequence.
EncodeSequence<T>(ref SliceEncoder, IEnumerable<T>)
Encodes a sequence of fixed-size numeric values, such as int or ulong.
public static void EncodeSequence<T>(this ref SliceEncoder encoder, IEnumerable<T> v) where T : struct
Parameters
encoderSliceEncoderThe Slice encoder.
vIEnumerable<T>The sequence of numeric values.
Type Parameters
TThe sequence element type.
EncodeSequence<T>(ref SliceEncoder, IEnumerable<T>, EncodeAction<T>)
Encodes a sequence.
public static void EncodeSequence<T>(this ref SliceEncoder encoder, IEnumerable<T> v, EncodeAction<T> encodeAction) where T : notnull
Parameters
encoderSliceEncoderThe Slice encoder.
vIEnumerable<T>The sequence to encode.
encodeActionEncodeAction<T>The encode action for an element.
Type Parameters
TThe type of the sequence elements.
EncodeSpan<T>(ref SliceEncoder, ReadOnlySpan<T>)
Encodes a span of fixed-size numeric values, such as int or ulong.
public static void EncodeSpan<T>(this ref SliceEncoder encoder, ReadOnlySpan<T> v) where T : struct
Parameters
encoderSliceEncoderThe Slice encoder.
vReadOnlySpan<T>The span of numeric values represented by a ReadOnlySpan<T>.
Type Parameters
TThe span element type.
WriteByteSequence(ref SliceEncoder, ReadOnlySequence<byte>)
Copies a sequence of bytes to the underlying buffer writer.
public static void WriteByteSequence(this ref SliceEncoder encoder, ReadOnlySequence<byte> v)
Parameters
encoderSliceEncoderThe Slice encoder.
vReadOnlySequence<byte>The sequence to copy.