public static bool TryFromJson(JToken token, out LaunchInvocation invocation) { var operation = token.Value <string>("operation"); if (string.IsNullOrEmpty(operation)) { invocation = default; return(false); } var contractJson = token["contract"]; var contract = contractJson == null ? string.Empty : contractJson.Value <string>(); var argsJson = token["args"]; var args = argsJson == null ? new JArray() : argsJson is JArray ? (JArray)argsJson : new JArray(argsJson); invocation = new LaunchInvocation(contract, operation, args); return(true); }
static bool TryGetInvocation(JToken json, out Invocation result) { if (json["invokeFile"] != null) { result = new InvokeFileInvocation(json.Value <string>("invokeFile")); return(true); } if (OracleResponseInvocation.TryFromJson(json["oracleResponse"], out var oracleInvocation)) { result = oracleInvocation; return(true); } if (LaunchInvocation.TryFromJson(json, out var launchInvocation)) { result = launchInvocation; return(true); } result = default; return(false); }