public string getString(string path, string key, string defaultValue) { SettingsRequestMessage newMessage = new SettingsRequestMessage(); SettingsRequestMessage.Types.Request.Types.Query newQuery = new SettingsRequestMessage.Types.Request.Types.Query(); newQuery.Node = new Node(); newQuery.Node.Path = path; newQuery.Node.Key = key; newQuery.DefaultValue = defaultValue; SettingsRequestMessage.Types.Request request = new SettingsRequestMessage.Types.Request(); request.PluginId = plugin_id; request.Query = newQuery; newMessage.Payload.Add(request); NSCP.Core.Result res = core.settings(newMessage.ToByteArray()); if (!res.result) { log.error("Failed to get value: " + path); return(defaultValue); } SettingsResponseMessage response_message = SettingsResponseMessage.Parser.ParseFrom(res.data); if (response_message.Payload[0].Result.Code != PB.Common.Result.Types.StatusCodeType.StatusOk) { log.error("Failed to get value: " + path); return(defaultValue); } return(response_message.Payload[0].Query.Node.Value); }
public List <string> getKeys(string path) { List <string> ret = new List <string>(); SettingsRequestMessage newMessage = new SettingsRequestMessage(); SettingsRequestMessage.Types.Request.Types.Query newQuery = new SettingsRequestMessage.Types.Request.Types.Query(); newQuery.Node = new Node(); newQuery.Node.Path = path; newQuery.Recursive = false; SettingsRequestMessage.Types.Request request = new SettingsRequestMessage.Types.Request(); request.PluginId = plugin_id; request.Query = newQuery; newMessage.Payload.Add(request); NSCP.Core.Result res = core.settings(newMessage.ToByteArray()); if (!res.result) { log.error("Failed to get value: " + path); return(ret); } SettingsResponseMessage response_message = SettingsResponseMessage.Parser.ParseFrom(res.data); if (response_message.Payload == null || response_message.Payload.Count == 0 || response_message.Payload[0].Result == null) { log.error("Failed to get value: " + path); return(ret); } if (response_message.Payload[0].Result.Code != PB.Common.Result.Types.StatusCodeType.StatusOk) { log.error("Failed to get value: " + path); return(ret); } foreach (Node node in response_message.Payload[0].Query.Nodes) { ret.Add(node.Value); } return(ret); }