12 private readonly
object? result;
14 private readonly
long? id;
15 private readonly
bool hasResult;
16 private readonly
bool hasError;
24 foreach (KeyValuePair<string, object> P
in JsonResponse)
29 if (P.Value is
string s)
34 throw new JsonRpcException(
"Unexpected response received: Unsupported JSON-RPC version: " + s);
37 throw new JsonRpcException(
"Unexpected response received: JSON-RPC version property is not a string.");
41 this.result = P.Value;
42 this.hasResult =
true;
47 if (P.Value is Dictionary<string, object>
Error &&
48 Error.TryGetValue(
"code", out
object Obj) &&
49 Obj is
int ErrorCode &&
50 Error.TryGetValue(
"message", out Obj) &&
51 Obj is
string ErrorMessage)
61 if (P.Value is
long l)
63 else if (P.Value is
int i)
65 else if (P.Value is
string s2 &&
long.TryParse(s2, out l))
68 throw new JsonRpcException(
"Unexpected response received: Id property is not a valid integer.");
72 throw new JsonRpcException(
"Unexpected response received: Unknown property: " + P.Key);
85 public object?
Result => this.result;
95 public long?
Id => this.id;
Base class for JSON-RPC error responses.
Base class for JSON-RPC exceptions.
Information about a JSON-RPC result.
bool HasError
If response has an error in Error, this property is true.
object? Result
Result of operation, if HasResult is true.
JsonRpcError? Error
Error of operation, if HasError is true.
long? Id
ID matching the request, if any.
bool HasResult
If response has a result in Result, this property is true.
JsonRpcVersion Version
JSON-RPC version.
JsonRpcResult(Dictionary< string, object > JsonResponse)
Information about a JSON-RPC result.
JsonRpcVersion
JSON-RPC version