Пример #1
0
        protected EgoiType walkMap(Dictionary <string, object> map)
        {
            EgoiType r = null;

            if (map.ContainsKey("key_0"))
            {
                EgoiMapList   mrl  = new EgoiMapList();
                List <String> keys = map.Keys.ToList <string>();
                keys.Sort();
                foreach (String k in keys)
                {
                    if (!k.StartsWith("key_"))
                    {
                        continue;
                    }
                    if (map [k] is Dictionary <string, object> )
                    {
                        mrl.Add(walkValues(new EgoiMap(map [k] as Dictionary <string, object>)));
                    }
                    else
                    {
                        EgoiMap value = new EgoiMap(); value.Add("value", map [k]); mrl.Add(value);
                    }
                }
                r = mrl;
            }
            else
            {
                r = walkValues(new EgoiMap(map));
            }

            return(r);
        }
Пример #2
0
        private EgoiMapList decodeResultMapList(object result)
        {
            checkResult(result);

            if (result is XmlRpcStruct[])
            {
                return(decodeMapList(result as XmlRpcStruct[]));
            }
            else if (result is XmlRpcStruct)
            {
                EgoiMapList list = new EgoiMapList();

                list.Add(decodeResultMap(result));

                return(list);
            }
            else if (result is object[]) // occurs when response is empty
            {
                return(new EgoiMapList());
            }
            else
            {
                throw new EgoiException("The response is of unexpected type: " + result + ", expecting XmlRpcStruct[]");
            }
        }
Пример #3
0
        private EgoiType walkArray(List <Dictionary <string, object> > list)
        {
            EgoiMapList mrl = new EgoiMapList();

            foreach (Dictionary <string, object> map in list)
            {
                mrl.Add(walkValues(new EgoiMap(map)));
            }
            return(mrl);
        }
Пример #4
0
        private EgoiMapList decodeMapList(XmlRpcStruct[] result)
        {
            EgoiMapList list = new EgoiMapList();

            foreach (XmlRpcStruct value in result)
            {
                list.Add(decodeMap(value));
            }
            return(list);
        }
Пример #5
0
        private EgoiMapList decodeMapList(object[] result)
        {
            EgoiMapList list = new EgoiMapList();

            if (result is XmlRpcStruct[])
            {
                foreach (XmlRpcStruct value in result)
                {
                    list.Add(decodeMap(value));
                }
            }

            if (result is string[])
            {
                foreach (string value in result)
                {
                    EgoiMap mapString = new EgoiMap();
                    mapString["value"] = value;
                    list.Add(mapString);
                }
            }

            return(list);
        }
Пример #6
0
        public EgoiMapList decodeMapListResult(String method, EgoiMap arguments)
        {
            Dictionary <string, object> result = processResult(method, arguments);

            EgoiType et = walkMap(result);

            if (et is EgoiMap)
            {
                EgoiMapList eml = new EgoiMapList();

                eml.Add(et as EgoiMap);

                et = eml;
            }

            return(et as EgoiMapList);
        }