Ejemplo n.º 1
0
        public bool SetOption(string taskid, string option, object value)
        {
            string json = "{ ";

            json += "\"" + option + "\" : ";

            if (value is string)
            {
                json += "\"" + (value as string) + "\"";
            }
            else if (value is bool)
            {
                json += ((bool)value ? "true" : "false");
            }
            else if (value is int)
            {
                json += value;
            }
            else
            {
                throw new Exception("Can't handle type: " + value.GetType().Name);
            }

            json += " }";

            JToken tok = JObject.Parse(_session.ExecutePost("/option/" + taskid + "/set", json));

            return((bool)tok.SelectToken("success"));
        }
        public bool SetOption(string taskid, string option, object value)
        {
            JObject json = new JObject();

            json [option] = JToken.FromObject(value);

            JToken tok = JObject.Parse(_session.ExecutePost("/option/" + taskid + "/set", json.ToString()));

            return((bool)tok.SelectToken("success"));
        }