Пример #1
0
        public static String prepareMapPayload(String prepend, EgoiMap values)
        {
            StringBuilder q = new StringBuilder();

            foreach (String key in values.Keys)
            {
                Object value  = values[key];
                String result = null;

                String prefix = String.Format("{0}[{1}]", prepend, key);

                if (value is EgoiMap)
                {
                    EgoiMap map = (EgoiMap)value;
                    result = prepareMapPayload(prefix, map);
                }
                else if (value is EgoiMapList)
                {
                    EgoiMapList list = (EgoiMapList)value;
                    result = prepareListPayload(prefix, list);
                }
                else if (value is EgoiList)
                {
                    EgoiList list = (EgoiList)value;
                    result = prepareGenericListPayload(prefix, list);
                }
                else
                {
                    result = String.Format("{0}={1}&", prefix, value.ToString());
                }

                q.Append(result);
            }
            return(q.ToString());
        }
Пример #2
0
        private static String prepareGenericListPayload(String prepend, EgoiList list)
        {
            StringBuilder q = new StringBuilder();

            for (int i = 0; i < list.Count(); i++)
            {
                String prefix = String.Format("{0}[{1}]", prepend, i);
                Object value  = list[i];
                String enc    = HttpUtility.UrlEncode(value.ToString());
                q.Append(String.Format("{0}={1}&", prefix, enc));
            }
            return(q.ToString());
        }