Table of Contents

Class MessageFormatterEnumerableTracker

Namespace
StreamJsonRpc.Reflection
Assembly
StreamJsonRpc.dll

A helper class that IJsonRpcMessageFormatter implementations may use to support IAsyncEnumerable<T> return values from RPC methods.

public class MessageFormatterEnumerableTracker
Inheritance
MessageFormatterEnumerableTracker
Inherited Members

Constructors

MessageFormatterEnumerableTracker(JsonRpc, IJsonRpcFormatterState)

Initializes a new instance of the MessageFormatterEnumerableTracker class.

public MessageFormatterEnumerableTracker(JsonRpc jsonRpc, IJsonRpcFormatterState formatterState)

Parameters

jsonRpc JsonRpc

The JsonRpc instance that may be used to send or receive RPC messages related to IAsyncEnumerable<T>.

formatterState IJsonRpcFormatterState

The formatter that owns this tracker.

Fields

TokenPropertyName

The name of the string property that carries the handle for the enumerable.

public const string TokenPropertyName = "token"

Field Value

string

ValuesPropertyName

The name of the JSON array property that contains the values.

public const string ValuesPropertyName = "values"

Field Value

string

Methods

CanDeserialize(Type)

Checks if a given Type is exactly some closed generic type based on IAsyncEnumerable<T>.

public static bool CanDeserialize(Type objectType)

Parameters

objectType Type

The type which may be IAsyncEnumerable<T>.

Returns

bool

true if given Type is IAsyncEnumerable<T>; otherwise, false.

CanSerialize(Type)

Checks if a given Type implements IAsyncEnumerable<T>.

public static bool CanSerialize(Type objectType)

Parameters

objectType Type

The type which may implement IAsyncEnumerable<T>.

Returns

bool

true if given Type implements IAsyncEnumerable<T>; otherwise, false.

CreateEnumerableProxy<T>(object?, IReadOnlyList<T>?)

Used by the consumer to construct a proxy that implements IAsyncEnumerable<T> and gets all its values from a remote generator.

public IAsyncEnumerable<T> CreateEnumerableProxy<T>(object? handle, IReadOnlyList<T>? prefetchedItems)

Parameters

handle object

The handle specified by the generator that is used to obtain more values or dispose of the enumerator. May be null to indicate there will be no more values.

prefetchedItems IReadOnlyList<T>

The list of items that are included with the enumerable handle.

Returns

IAsyncEnumerable<T>

The enumerator.

Type Parameters

T

The type of value that is produced by the enumerable.

GetToken<T>(IAsyncEnumerable<T>)

Used by the generator to assign a handle to the given IAsyncEnumerable<T>.

public long GetToken<T>(IAsyncEnumerable<T> enumerable)

Parameters

enumerable IAsyncEnumerable<T>

The enumerable to assign a handle to.

Returns

long

The handle that was assigned.

Type Parameters

T

The type of value that is produced by the enumerable.