/// <summary>Creates a deep copy of the item specified</summary>
        /// <param name="item">The item to copy</param>
        /// <remarks>The function makes a deep copy of quite a lot which can be slow</remarks>
        public HttpInputItem(HttpInputItem item)
        {
            foreach (KeyValuePair <string, HttpInputItem> pair in item._items)
            {
                _items.Add(pair.Key, pair.Value);
            }

            foreach (string value in item._values)
            {
                _values.Add(value);
            }

            _ignoreChanges = item._ignoreChanges;
            _name          = item.Name;
        }
Beispiel #2
0
        /// <summary>
        /// Parses an item and returns it.
        /// This function is primarily used to parse array items as in user[name].
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static HttpInputItem ParseItem(string name, string value)
        {
            HttpInputItem item;

            // Check if it's a sub item.
            // we can have multiple levels of sub items as in user[extension[id]]] => user -> extension -> id
            int pos = name.IndexOf('[');

            if (pos != -1)
            {
                string name1 = name.Substring(0, pos);
                string name2 = ExtractOne(name);
                item = new HttpInputItem(name1, null);
                item.Add(name2, value);
            }
            else
            {
                item = new HttpInputItem(name, value);
            }

            return(item);
        }