Example #1
0
        // Works for strings, binary data, arrays, and structs.

        public void Copy(XmlRpcValue other)
        {
            switch (other._type)
            {
            case ValueType.TypeBoolean:
                asBool = other.asBool;
                break;

            case ValueType.TypeInt:
                asInt = other.asInt;
                break;

            case ValueType.TypeDouble:
                asDouble = other.asDouble;
                break;

            case ValueType.TypeDateTime:
                asTime = other.asTime;
                break;

            case ValueType.TypeString:
                asString = other.asString;
                break;

            case ValueType.TypeBase64:
                asBinary = other.asBinary;
                break;

            case ValueType.TypeArray:
                asArray = other.asArray;
                break;

            // The map<>::operator== requires the definition of value< for kcc
            case ValueType.TypeStruct:     //return *_value.asStruct == *other._value.asStruct;
                asStruct = other.asStruct;
                break;
            }
            _type = other._type;
        }
Example #2
0
 public bool ExecuteCheckDone(XmlRpcValue result)
 {
     return(executecheckdone(instance, result.instance));
 }
Example #3
0
 public bool ExecuteNonBlock(string method, XmlRpcValue parameters)
 {
     return(executenonblock(instance, method, parameters.instance));
 }
Example #4
0
        public bool Execute(string method, XmlRpcValue parameters, XmlRpcValue result)
        {
            bool r = execute(instance, method, parameters.instance, result.instance);

            return(r);
        }
Example #5
0
        public bool fromXml(XmlNode value)
        {
            //int val = offset;
            //offset = 0;
            try
            {
                //XmlElement value = node["value"];
                if (value == null)
                {
                    return(false);
                }

                string     tex = value.InnerText;
                XmlElement val;
                if ((val = value[BOOLEAN_TAG]) != null)
                {
                    _type = ValueType.TypeBoolean;
                    int tmp = 0;
                    if (!int.TryParse(tex, out tmp))
                    {
                        return(false);
                    }
                    if (tmp != 0 && tmp != 1)
                    {
                        return(false);
                    }
                    asBool = (tmp == 0 ? false : true);
                }
                else if ((val = value[I4_TAG]) != null)
                {
                    _type = ValueType.TypeInt;
                    return(int.TryParse(tex, out asInt));
                }
                else if ((val = value[INT_TAG]) != null)
                {
                    _type = ValueType.TypeInt;
                    return(int.TryParse(tex, out asInt));
                }
                else if ((val = value[DOUBLE_TAG]) != null)
                {
                    _type = ValueType.TypeDouble;
                    return(double.TryParse(tex, out asDouble));
                }
                else if ((val = value[DATETIME_TAG]) != null)
                {
                    // TODO: implement
                }
                else if ((val = value[BASE64_TAG]) != null)
                {
                    // TODO: implement
                }
                else if ((val = value[STRING_TAG]) != null)
                {
                    _type    = ValueType.TypeString;
                    asString = tex;
                }
                else if ((val = value[ARRAY_TAG]) != null)
                {
                    var data = val[DATA_TAG];
                    if (data == null)
                    {
                        return(false);
                    }
                    var selection = data.SelectNodes(VALUE_TAG);
                    SetArray(selection.Count);
                    for (int i = 0; i < selection.Count; i++)
                    {
                        var xmlValue = new XmlRpcValue();
                        if (!xmlValue.fromXml(selection[i]))
                        {
                            return(false);
                        }
                        asArray[i] = xmlValue;
                    }
                }
                else if ((val = value[STRUCT_TAG]) != null)
                {
                    // TODO: implement
                }
                else
                {
                    _type    = ValueType.TypeString;
                    asString = tex;
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Example #6
0
 public void _param_update_task(String caller_id, String caller_api, String param_key, XmlRpc_Wrapper.XmlRpcValue param_value)
 {
 }
Example #7
0
 private void execute(XmlRpcValue parms, XmlRpcValue result)
 {
     server.listMethods(result);
 }
 public void Execute(XmlRpcValue parms, XmlRpcValue reseseses)
 {
     _FUNC(parms, reseseses);
 }
Example #9
0
 public Param(XmlRpc_Wrapper.XmlRpcValue val)
 {
     _value = val;
 }
Example #10
0
        // Convert the response xml into a result value
        private bool parseResponse(XmlRpcValue result, string _response)
        {
            bool success = true;

            //XmlRpcValue result = null;
            using (XmlReader reader = XmlReader.Create(new StringReader(_response)))
            {
                XmlDocument response = new XmlDocument();
                response.Load(reader);
                // Parse response xml into result
                //int offset = 0;
                XmlNodeList resp         = response.GetElementsByTagName("methodResponse");
                XmlNode     responseNode = resp[0];

                //if (!XmlRpcUtil.findTag(METHODRESPONSE_TAG, _response, out offset))
                if (resp.Count == 0)
                {
                    XmlRpcUtil.error("Error in XmlRpcClient::parseResponse: Invalid response - no methodResponse. Response:\n{0}", _response);
                    return(false);
                }

                XmlElement pars  = responseNode["params"];
                XmlElement fault = responseNode["fault"];

                //result = new XmlRpcValue();
                if (pars != null)
                {
                    bool isArray   = false;
                    var  selection = pars.SelectNodes("param");
                    if (selection.Count > 1)
                    {
                        result.SetArray(selection.Count);
                        int i = 0;
                        foreach (XmlNode par in selection)
                        {
                            var value = new XmlRpcValue();
                            value.fromXml(par["value"]);
                            result[i++] = value;
                        }
                    }
                    else if (selection.Count == 1)
                    {
                        result.fromXml(selection[0]["value"]);
                    }
                    else
                    {
                        success = false;
                    }
                }
                else if (fault != null && result.fromXml(fault))
                {
                    success = false;
                }
                else
                {
                    XmlRpcUtil.error("Error in XmlRpcClient::parseResponse: Invalid response - no param or fault tag. Response:\n{0}", _response);
                }
                _response = "";
            }
            return(success);
        }
Example #11
0
 public XmlRpcValue(XmlRpcValue value)
     : this(value.instance)
 {
 }
Example #12
0
 public void Execute(XmlRpcValue parms, out XmlRpcValue reseseses)
 {
     SegFault();
     reseseses = new XmlRpcValue();
     execute(instance, parms.instance, reseseses.instance);
 }