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
JsonRpcThe JsonRpc object that ultimately owns this tracker.
formatterState
IJsonRpcFormatterStateThe formatter that owns this tracker.
Fields
ProgressRequestSpecialMethod
Special method name for progress notification.
public const string ProgressRequestSpecialMethod = "$/progress"
Field Value
Methods
CanDeserialize(Type)
Checks if a given Type is a closed generic of IProgress<T>.
public static bool CanDeserialize(Type objectType)
Parameters
objectType
TypeThe 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
TypeThe 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
JsonRpcThe JsonRpc instance used to send the ProgressRequestSpecialMethod notification.
token
objectThe token used to obtain the MessageFormatterProgressTracker.ProgressParamInformation instance from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.
valueType
TypeA generic type whose first generic type argument is to serve as the type argument for the created IProgress<T>.
Returns
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
JsonRpcThe JsonRpc instance used to send the ProgressRequestSpecialMethod notification.
token
objectThe token used to obtain the MessageFormatterProgressTracker.ProgressParamInformation instance from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.
valueType
TypeA generic type whose first generic type argument is to serve as the type argument for the created IProgress<T>.
clientRequiresNamedArguments
booltrue to issue $/progress notifications using named args; false to use positional arguments.
Returns
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
JsonRpcThe JsonRpc instance used to send the ProgressRequestSpecialMethod notification.
token
objectThe 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
JsonRpcThe JsonRpc instance used to send the ProgressRequestSpecialMethod notification.
token
objectThe token used to obtain the MessageFormatterProgressTracker.ProgressParamInformation instance from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.
clientRequiresNamedArguments
booltrue 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
TypeThe 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
objectThe object which should implement IProgress<T>.
Returns
IsSupportedProgressType(Type)
Checks if a given Type implements IProgress<T>.
[Obsolete("Use CanSerialize instead.")]
public static bool IsSupportedProgressType(Type objectType)
Parameters
objectType
TypeThe 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
longThe key to obtain the MessageFormatterProgressTracker.ProgressParamInformation object from StreamJsonRpc.Reflection.MessageFormatterProgressTracker.progressMap.
valueType
MessageFormatterProgressTracker.ProgressParamInformationOutput parameter to store the obtained MessageFormatterProgressTracker.ProgressParamInformation object.
Returns
- bool
true if the MessageFormatterProgressTracker.ProgressParamInformation object was found with the specified key; otherwise, false.