/// <summary>Creates a deep copy of the HttpInput class</summary>
        /// <param name="input">The object to copy</param>
        /// <remarks>The function makes a deep copy of quite a lot which can be slow</remarks>
        protected HttpInput(HttpInput input)
        {
            foreach (HttpInputItem item in input)
            {
                _items.Add(item.Name, new HttpInputItem(item));
            }

            _name          = input._name;
            _ignoreChanges = input._ignoreChanges;
        }
Esempio n. 2
0
        /// <summary>
        /// Add a sub item.
        /// </summary>
        /// <param name="name">Can contain array formatting, the item is then parsed and added in multiple levels</param>
        /// <param name="value">Value to add.</param>
        /// <exception cref="ArgumentNullException">Argument is null.</exception>
        /// <exception cref="InvalidOperationException">Cannot add stuff to <see cref="HttpInput.Empty"/>.</exception>
        public void Add(string name, string value)
        {
            if (name == null && value != null)
            {
                throw new ArgumentNullException("name");
            }
            if (name == null)
            {
                return;
            }
            if (_ignoreChanges)
            {
                throw new InvalidOperationException("Cannot add stuff to HttpInput.Empty.");
            }

            int pos = name.IndexOf('[');

            if (pos != -1)
            {
                string name1 = name.Substring(0, pos);
                string name2 = HttpInput.ExtractOne(name);
                if (!_items.ContainsKey(name1))
                {
                    _items.Add(name1, new HttpInputItem(name1, null));
                }
                _items[name1].Add(name2, value);

                /*
                 * HttpInputItem item = HttpInput.ParseItem(name, value);
                 *
                 * // Add the value to an existing sub item
                 * if (_items.ContainsKey(item.Name))
                 *  _items[item.Name].Add(item.Value);
                 * else
                 *  _items.Add(item.Name, item);
                 */
            }
            else
            {
                if (_items.ContainsKey(name))
                {
                    _items[name].Add(value);
                }
                else
                {
                    _items.Add(name, new HttpInputItem(name, value));
                }
            }
        }
Esempio n. 3
0
 internal void SetForm(HttpInput form)
 {
     m_form = form;
 }
Esempio n. 4
0
 internal void SetQueryString(HttpInput query)
 {
     m_query = query;
 }