Table of Contents

Class SliceEncoderExtensions

Namespace
ZeroC.Slice
Assembly
ZeroC.Slice.dll

Provides extension methods for SliceEncoder to encode sequences or dictionaries.

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

encoder SliceEncoder

The Slice encoder.

v IEnumerable<KeyValuePair<TKey, TValue>>

The dictionary to encode.

keyEncodeAction EncodeAction<TKey>

The encode action for the keys.

valueEncodeAction EncodeAction<TValue>

The encode action for the non-null values.

Type Parameters

TKey

The dictionary key type.

TValue

The 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

encoder SliceEncoder

The Slice encoder.

v IEnumerable<KeyValuePair<TKey, TValue>>

The dictionary to encode.

keyEncodeAction EncodeAction<TKey>

The encode action for the keys.

valueEncodeAction EncodeAction<TValue>

The encode action for the values.

Type Parameters

TKey

The dictionary key type.

TValue

The 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

encoder SliceEncoder

The Slice encoder.

v Result<TSuccess, TFailure>

The result to encode.

successEncodeAction EncodeAction<TSuccess>

The encode action for the success type.

failureEncodeAction EncodeAction<TFailure>

The encode action for the failure type.

Type Parameters

TSuccess

The type of the success value.

TFailure

The 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

encoder SliceEncoder

The Slice encoder.

v IEnumerable<T>

The sequence to encode.

encodeAction EncodeAction<T>

The encode action for a non-null value.

Type Parameters

T

The 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

encoder SliceEncoder

The Slice encoder.

v IEnumerable<T>

The sequence of numeric values.

Type Parameters

T

The 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)

Parameters

encoder SliceEncoder

The Slice encoder.

v IEnumerable<T>

The sequence to encode.

encodeAction EncodeAction<T>

The encode action for an element.

Type Parameters

T

The type of the sequence elements. It is non-nullable except for nullable class and nullable custom types with Slice1.

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

encoder SliceEncoder

The Slice encoder.

v ReadOnlySpan<T>

The span of numeric values represented by a ReadOnlySpan<T>.

Type Parameters

T

The 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

encoder SliceEncoder

The Slice encoder.

v ReadOnlySequence<byte>

The sequence to copy.