mirror of
https://github.com/StarBeat/JsonRpc.git
synced 2026-03-08 03:55:29 +08:00
39 lines
916 B
C#
39 lines
916 B
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace JsonRPC.Protocol
|
|
{
|
|
[Serializable]
|
|
public class JsonRPCRequest
|
|
{
|
|
[JsonPropertyName("method")]
|
|
public string Method { get; private set; }
|
|
|
|
[JsonPropertyName("params")]
|
|
public List<object> Params { get; private set; } = new();
|
|
|
|
[JsonPropertyName("id")]
|
|
public int Id { get; private set; }
|
|
|
|
[JsonPropertyName("jsonrpc")]
|
|
public EJsonRPCVersion Version => EJsonRPCVersion.Version2;
|
|
|
|
public JsonRPCRequest(string method, int id)
|
|
{
|
|
if (string.IsNullOrEmpty(method))
|
|
{
|
|
throw new ArgumentNullException(method);
|
|
}
|
|
|
|
this.Method = method;
|
|
this.Id = id;
|
|
}
|
|
|
|
public JsonRPCRequest AddParam(object param)
|
|
{
|
|
this.Params.Add(param);
|
|
return this;
|
|
}
|
|
|
|
}
|
|
}
|