Class JsonRpcResult
- Namespace
- StreamJsonRpc.Protocol
- Assembly
- StreamJsonRpc.dll
Describes the result of a successful method invocation.
[DataContract]
[GenerateShape]
[MessagePackConverter(typeof(NerdbankMessagePackFormatter.JsonRpcResultConverter))]
public class JsonRpcResult : JsonRpcMessage, IJsonRpcMessageWithId
- Inheritance
-
JsonRpcResult
- Implements
- Derived
- Inherited Members
Properties
DebuggerDisplay
Gets the string to display in the debugger for this instance.
protected string DebuggerDisplay { get; }
Property Value
Id
Gets or sets an identifier established by the client if a response to the request is expected.
[Obsolete("Use RequestId instead.")]
[IgnoreDataMember]
[JsonIgnore]
[PropertyShape(Ignore = true)]
public object? Id { get; set; }
Property Value
RequestId
Gets or sets an identifier established by the client if a response to the request is expected.
[DataMember(Name = "id", Order = 1, IsRequired = true)]
[JsonPropertyName("id")]
[JsonPropertyOrder(1)]
[JsonRequired]
[PropertyShape(Name = "id", Order = 1)]
public RequestId RequestId { get; set; }
Property Value
Result
Gets or sets the value of the result of an invocation, if any.
[DataMember(Name = "result", Order = 2, IsRequired = true, EmitDefaultValue = true)]
[JsonPropertyName("result")]
[JsonPropertyOrder(2)]
[JsonRequired]
[PropertyShape(Name = "result", Order = 2)]
public object? Result { get; set; }
Property Value
ResultDeclaredType
Gets or sets the declared type of the return value.
[IgnoreDataMember]
[JsonIgnore]
[PropertyShape(Ignore = true)]
public Type? ResultDeclaredType { get; set; }
Property Value
Remarks
This value is not serialized, but is used by the RPC server to assist in serialization where necessary.
Methods
GetResult<T>()
Gets the value of the Result, taking into account any possible type coercion.
public virtual T GetResult<T>()
Returns
- T
The result.
Type Parameters
Remarks
Derived types may override this method in order to deserialize the Result
such that it can be assignable to T
.
SetExpectedResultType(Type)
Provides a hint for a deferred deserialization of the Result value as to the type argument that will be used when calling GetResult<T>() later.
protected virtual void SetExpectedResultType(Type resultType)
Parameters
resultType
TypeThe type that will be used as the generic type argument to GetResult<T>().
ToString()
public override string ToString()