Class JsonRpcExtensions
- Namespace
- StreamJsonRpc
- Assembly
- StreamJsonRpc.dll
Extension methods for use with JsonRpc.
public static class JsonRpcExtensions
- Inheritance
-
JsonRpcExtensions
- Inherited Members
Methods
AsAsyncEnumerable<T>(IEnumerable<T>)
Converts an IEnumerable<T> to IAsyncEnumerable<T> so it will be streamed over an RPC connection progressively instead of as an entire collection in one message.
public static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this IEnumerable<T> enumerable)
Parameters
enumerableIEnumerable<T>The enumerable to be converted.
Returns
- IAsyncEnumerable<T>
The async enumerable instance.
Type Parameters
TThe type of element enumerated by the sequence.
AsAsyncEnumerable<T>(IEnumerable<T>, JsonRpcEnumerableSettings?)
Converts an IEnumerable<T> to IAsyncEnumerable<T> so it will be streamed over an RPC connection progressively instead of as an entire collection in one message.
public static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this IEnumerable<T> enumerable, JsonRpcEnumerableSettings? settings)
Parameters
enumerableIEnumerable<T>The enumerable to be converted.
settingsJsonRpcEnumerableSettingsThe settings to associate with this enumerable.
Returns
- IAsyncEnumerable<T>
The async enumerable instance.
Type Parameters
TThe type of element enumerated by the sequence.
AsAsyncEnumerable<T>(IEnumerable<T>, JsonRpcEnumerableSettings?, CancellationToken)
Converts an IEnumerable<T> to IAsyncEnumerable<T> so it will be streamed over an RPC connection progressively instead of as an entire collection in one message.
public static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this IEnumerable<T> enumerable, JsonRpcEnumerableSettings? settings, CancellationToken cancellationToken)
Parameters
enumerableIEnumerable<T>The enumerable to be converted.
settingsJsonRpcEnumerableSettingsThe settings to associate with this enumerable.
cancellationTokenCancellationTokenA cancellation token.
Returns
- IAsyncEnumerable<T>
The async enumerable instance.
Type Parameters
TThe type of element enumerated by the sequence.
AsAsyncEnumerable<T>(IEnumerable<T>, CancellationToken)
Converts an IEnumerable<T> to IAsyncEnumerable<T> so it will be streamed over an RPC connection progressively instead of as an entire collection in one message.
public static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this IEnumerable<T> enumerable, CancellationToken cancellationToken)
Parameters
enumerableIEnumerable<T>The enumerable to be converted.
cancellationTokenCancellationTokenA cancellation token.
Returns
- IAsyncEnumerable<T>
The async enumerable instance.
Type Parameters
TThe type of element enumerated by the sequence.
As<T>(IClientProxy?)
Casts the proxy to the requested interface type, if it (intentionally) implements it.
public static T? As<T>(this IClientProxy? proxy) where T : class
Parameters
proxyIClientProxy
Returns
- T
The receiving object, cast to the requested interface if the proxy implements it and the interface was requested at proxy instantiation time; otherwise null.
Type Parameters
T- A contract interface type.
Remarks
Typically a simple conditional cast would be sufficient to determine whether a proxy implements a given interface. However when AcceptProxyWithExtraInterfaces is true a proxy may be returned that implements extra interfaces. In such cases, this method can be used to determine whether the proxy was intentionally created to implement the interface or not, allowing feature testing to still happen since conditional casting might lead to false positives.
WithJsonRpcSettings<T>(IAsyncEnumerable<T>, JsonRpcEnumerableSettings?)
Decorates an IAsyncEnumerable<T> with settings that customize how StreamJsonRpc will send its items to the remote party.
public static IAsyncEnumerable<T> WithJsonRpcSettings<T>(this IAsyncEnumerable<T> enumerable, JsonRpcEnumerableSettings? settings)
Parameters
enumerableIAsyncEnumerable<T>The enumerable to be decorated.
settingsJsonRpcEnumerableSettingsThe settings to associate with this enumerable.
Returns
- IAsyncEnumerable<T>
The decorated enumerable instance.
Type Parameters
TThe type of element enumerated by the sequence.
WithPrefetchAsync<T>(IAsyncEnumerable<T>, int, CancellationToken)
Preloads an IAsyncEnumerable<T> with a cache of pre-enumerated items for inclusion in the initial transmission of the enumerable over an RPC channel.
public static ValueTask<IAsyncEnumerable<T>> WithPrefetchAsync<T>(this IAsyncEnumerable<T> enumerable, int count, CancellationToken cancellationToken = default)
Parameters
enumerableIAsyncEnumerable<T>The sequence to pre-fetch items from.
countintThe number of items to pre-fetch. If this value is larger than the number of elements in the enumerable, all values will be pre-fetched.
cancellationTokenCancellationTokenA cancellation token.
Returns
- ValueTask<IAsyncEnumerable<T>>
A decorated IAsyncEnumerable<T> object that is specially prepared for processing by JSON-RPC with the preloaded values.
Type Parameters
TThe type of item in the collection.