private JsonValue getValue(Common.StringView name) { JsonValue val = chain[chain.Count - 1].functorMethod; if (val.isArray()) { return(val[idxs[idxs.Count - 1]++]); } string strName = name; return(val.contains(strName) ? &val(strName) : null); }
public override bool BeginArray(ref ulong size, Common.StringView name) { JsonValue parent = chain[chain.Count - 1].functorMethod; string strName = name; if (parent.contains(strName)) { JsonValue arr = parent(strName); size = arr.size(); chain.Add(arr); idxs.Add(0); return(true); } size = 0; return(false); }
public override bool BeginObject(Common.StringView name) { JsonValue parent = chain[chain.Count - 1].functorMethod; if (parent.isArray()) { JsonValue v = parent[idxs[idxs.Count - 1]++]; chain.Add(v); return(true); } if (parent.contains((string)name)) { JsonValue v = parent((string)name); chain.Add(v); return(true); } return(false); }
//C++ TO C# CONVERTER TODO TASK: C# has no equivalent to ' = delete': // PaymentServiceJsonRpcServer(const PaymentServiceJsonRpcServer&) = delete; protected override void processJsonRpcRequest(Common.JsonValue req, Common.JsonValue resp) { try { prepareJsonResponse(req.functorMethod, resp.functorMethod); if (!config.serviceConfig.legacySecurity) { string clientPassword; if (!req.contains("password")) { makeInvalidPasswordResponse(resp.functorMethod); return; } if (!req.functorMethod("password").isString()) { makeInvalidPasswordResponse(resp.functorMethod); return; } clientPassword = req.functorMethod("password").getString(); List <byte> rawData = new List <byte>(clientPassword.GetEnumerator(), clientPassword.end()); Crypto.Hash hashedPassword = new Crypto.Hash(); Crypto.GlobalMembers.cn_slow_hash_v0(rawData.data(), rawData.Count, hashedPassword); if (hashedPassword != config.rpcSecret) { makeInvalidPasswordResponse(resp.functorMethod); return; } } if (!req.contains("method")) { logger.functorMethod(Logging.Level.WARNING) << "Field \"method\" is not found in json request: " << req.functorMethod; makeGenericErrorReponse(resp.functorMethod, "Invalid Request", -3600); return; } if (!req.functorMethod("method").isString()) { logger.functorMethod(Logging.Level.WARNING) << "Field \"method\" is not a string type: " << req.functorMethod; makeGenericErrorReponse(resp.functorMethod, "Invalid Request", -3600); return; } string method = req.functorMethod("method").getString(); var it = handlers.find(method); if (it == handlers.end()) { logger.functorMethod(Logging.Level.WARNING) << "Requested method not found: " << method; makeMethodNotFoundResponse(resp.functorMethod); return; } logger.functorMethod(Logging.Level.DEBUGGING) << method << " request came"; Common.JsonValue @params = new Common.JsonValue(Common.JsonValue.OBJECT); if (req.contains("params")) { @params = req.functorMethod("params"); } //C++ TO C# CONVERTER TODO TASK: Iterators are only converted within the context of 'while' and 'for' loops: it.second(@params.functorMethod, resp.functorMethod); } catch (System.Exception e) { logger.functorMethod(Logging.Level.WARNING) << "Error occurred while processing JsonRpc request: " << e.Message; makeGenericErrorReponse(resp.functorMethod, e.Message); } }