Table of Contents

Class MessageFormatterProgressTracker

Namespace
StreamJsonRpc.Reflection
Assembly
StreamJsonRpc.dll

Class containing useful methods to help message formatters implement support for IProgress<T>.

public class MessageFormatterProgressTracker
Inheritance
MessageFormatterProgressTracker
Inherited Members

Constructors

MessageFormatterProgressTracker(JsonRpc, IJsonRpcFormatterState)

Initializes a new instance of the MessageFormatterProgressTracker class.

public MessageFormatterProgressTracker(JsonRpc jsonRpc, IJsonRpcFormatterState formatterState)

Parameters

jsonRpc JsonRpc

The JsonRpc object that ultimately owns this tracker.

formatterState IJsonRpcFormatterState

The formatter that owns this tracker.

Fields

ProgressRequestSpecialMethod

Special method name for progress notification.

public const string ProgressRequestSpecialMethod = "$/progress"

Field Value

string

Methods

CanDeserialize(Type)

Checks if a given Type is a closed generic of IProgress<T>.

public static bool CanDeserialize(Type objectType)

Parameters

objectType Type

The type which may be IProgress<T>.

Returns

bool

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

CanSerialize(Type)

Checks if a given Type implements IProgress<T>.

public static bool CanSerialize(Type objectType)

Parameters

objectType Type

The type which may implement IProgress<T>.

Returns

bool

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

CreateProgress(JsonRpc, object, Type)

Creates a new instance of IProgress<T> to use on the receiving end of an RPC call.

public object CreateProgress(JsonRpc rpc, object token, Type valueType)

Parameters

rpc JsonRpc

The JsonRpc instance used to send the ProgressRequestSpecialMethod notification.

token object

The token used to obtain the MessageFormatterProgressTracker.ProgressParamInformation instance from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.

valueType Type

A generic type whose first generic type argument is to serve as the type argument for the created IProgress<T>.

Returns

object

Remarks

This overload creates an IProgress<T> that does not use named arguments in its notifications.

CreateProgress(JsonRpc, object, Type, bool)

Creates a new instance of IProgress<T> to use on the receiving end of an RPC call.

public object CreateProgress(JsonRpc rpc, object token, Type valueType, bool clientRequiresNamedArguments)

Parameters

rpc JsonRpc

The JsonRpc instance used to send the ProgressRequestSpecialMethod notification.

token object

The token used to obtain the MessageFormatterProgressTracker.ProgressParamInformation instance from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.

valueType Type

A generic type whose first generic type argument is to serve as the type argument for the created IProgress<T>.

clientRequiresNamedArguments bool

true to issue $/progress notifications using named args; false to use positional arguments.

Returns

object

CreateProgress<T>(JsonRpc, object)

Creates a new instance of IProgress<T> to use on the receiving end of an RPC call.

public IProgress<T> CreateProgress<T>(JsonRpc rpc, object token)

Parameters

rpc JsonRpc

The JsonRpc instance used to send the ProgressRequestSpecialMethod notification.

token object

The token used to obtain the MessageFormatterProgressTracker.ProgressParamInformation instance from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.

Returns

IProgress<T>

Type Parameters

T

Remarks

This overload creates an IProgress<T> that does not use named arguments in its notifications.

CreateProgress<T>(JsonRpc, object, bool)

Creates a new instance of IProgress<T> to use on the receiving end of an RPC call.

public IProgress<T> CreateProgress<T>(JsonRpc rpc, object token, bool clientRequiresNamedArguments)

Parameters

rpc JsonRpc

The JsonRpc instance used to send the ProgressRequestSpecialMethod notification.

token object

The token used to obtain the MessageFormatterProgressTracker.ProgressParamInformation instance from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.

clientRequiresNamedArguments bool

true to issue $/progress notifications using named args; false to use positional arguments.

Returns

IProgress<T>

Type Parameters

T

The type of the value to be reported by IProgress<T>.

FindIProgressOfT(Type)

Converts given Type to its IProgress<T> type.

public static Type? FindIProgressOfT(Type objectType)

Parameters

objectType Type

The type which may implement IProgress<T>.

Returns

Type

The IProgress<T> from given Type object, or null if no such interface was found in the given objectType.

GetTokenForProgress(object)

Gets a long type token to use as replacement of an object implementing IProgress<T> in the JSON message.

public long GetTokenForProgress(object value)

Parameters

value object

The object which should implement IProgress<T>.

Returns

long

The assigned long typed token.

IsSupportedProgressType(Type)

Checks if a given Type implements IProgress<T>.

[Obsolete("Use CanSerialize instead.")]
public static bool IsSupportedProgressType(Type objectType)

Parameters

objectType Type

The type which may implement IProgress<T>.

Returns

bool

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

TryGetProgressObject(long, out ProgressParamInformation?)

Gets the MessageFormatterProgressTracker.ProgressParamInformation object associated with the given progress id.

public bool TryGetProgressObject(long progressId, out MessageFormatterProgressTracker.ProgressParamInformation? valueType)

Parameters

progressId long

The key to obtain the MessageFormatterProgressTracker.ProgressParamInformation object from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.

valueType MessageFormatterProgressTracker.ProgressParamInformation

Output parameter to store the obtained MessageFormatterProgressTracker.ProgressParamInformation object.

Returns

bool

true if the MessageFormatterProgressTracker.ProgressParamInformation object was found with the specified key; otherwise, false.