Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Iterator in RpcClient #629

Open
RichardBelsum opened this issue Aug 17, 2021 · 0 comments
Open

Support Iterator in RpcClient #629

RichardBelsum opened this issue Aug 17, 2021 · 0 comments

Comments

@RichardBelsum
Copy link
Contributor

RichardBelsum commented Aug 17, 2021

public static StackItem StackItemFromJson(JObject json)
{
StackItemType type = json["type"].TryGetEnum<StackItemType>();
switch (type)
{
case StackItemType.Boolean:
return new Boolean(json["value"].AsBoolean());
case StackItemType.Buffer:
return new Buffer(Convert.FromBase64String(json["value"].AsString()));
case StackItemType.ByteString:
return new ByteString(Convert.FromBase64String(json["value"].AsString()));
case StackItemType.Integer:
return BigInteger.Parse(json["value"].AsString());
case StackItemType.Array:
Array array = new();
foreach (var item in (JArray)json["value"])
array.Add(StackItemFromJson(item));
return array;
case StackItemType.Struct:
Struct @struct = new();
foreach (var item in (JArray)json["value"])
@struct.Add(StackItemFromJson(item));
return @struct;
case StackItemType.Map:
Map map = new();
foreach (var item in (JArray)json["value"])
{
PrimitiveType key = (PrimitiveType)StackItemFromJson(item["key"]);
map[key] = StackItemFromJson(item["value"]);
}
return map;
case StackItemType.Pointer:
return new Pointer(null, (int)json["value"].AsNumber());
case StackItemType.InteropInterface:
return new InteropInterface(new object());
}
return json["value"] is null ? StackItem.Null : json["value"].AsString();
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant