42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
|
using ln.type.rpc;
|
|
|
|
namespace ln.json.mapping
|
|
{
|
|
public class JSONRPCCallMapping : JSONMapping
|
|
{
|
|
public JSONRPCCallMapping()
|
|
:base(typeof(RPCCall))
|
|
{
|
|
}
|
|
|
|
public override object FromJson(JSONMapper mapper, JSONValue jsonValue)
|
|
{
|
|
JSONObject json = jsonValue as JSONObject;
|
|
RPCCall call = new RPCCall();
|
|
|
|
if (json.ContainsKey("id"))
|
|
{
|
|
call.Identifier = json["id"].ToNative();
|
|
}
|
|
else
|
|
{
|
|
call.Identifier = Guid.NewGuid();
|
|
}
|
|
|
|
if (json.ContainsKey("module"))
|
|
call.ModuleName = JSONMapper.DefaultMapper.FromJson<string>(json["module"]);
|
|
|
|
if (json.ContainsKey("method"))
|
|
call.MethodName = JSONMapper.DefaultMapper.FromJson<string>(json["method"]);
|
|
|
|
if (json.ContainsKey("parameters"))
|
|
call.Parameters = JSONMapper.DefaultMapper.FromJson<object[]>(json["parameters"]);
|
|
else
|
|
call.Parameters = new object[0];
|
|
|
|
return call;
|
|
}
|
|
}
|
|
}
|