Example #1
0
        public void Add(NameValueCollection c)
        {
            if (this.IsReadOnly)
            {
                throw new NotSupportedException("Collection is read-only");
            }
#if NET_2_0
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
#endif
            // make sense - but it's not the exception thrown
            //        throw new ArgumentNullException ();

            InvalidateCachedArrays();
            int max = c.Count;
            for (int i = 0; i < max; i++)
            {
                string     key        = c.GetKey(i);
                List <int> new_values = (List <int>)c.BaseGet(i);
                List <int> values     = (List <int>)BaseGet(key);
                if (values != null && new_values != null)
                {
                    values.AddRange(new_values);
                }
                else if (new_values != null)
                {
                    values = new List <int>(new_values);
                }
                BaseSet(key, values);
            }
        }
Example #2
0
        /// <summary>Copies the entries in the specified <see cref="T:System.Collections.Specialized.NameValueCollection" /> to the current <see cref="T:System.Collections.Specialized.NameValueCollection" />.</summary>
        /// <param name="c">The <see cref="T:System.Collections.Specialized.NameValueCollection" /> to copy to the current <see cref="T:System.Collections.Specialized.NameValueCollection" />.</param>
        /// <exception cref="T:System.NotSupportedException">The collection is read-only.</exception>
        /// <exception cref="T:System.ArgumentNullException">
        ///   <paramref name="c" /> is null.</exception>
        public void Add(NameValueCollection c)
        {
            if (base.IsReadOnly)
            {
                throw new NotSupportedException("Collection is read-only");
            }
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            InvalidateCachedArrays();
            int count = c.Count;

            for (int i = 0; i < count; i++)
            {
                string    key        = c.GetKey(i);
                ArrayList arrayList  = (ArrayList)c.BaseGet(i);
                ArrayList arrayList2 = (ArrayList)BaseGet(key);
                if (arrayList2 != null && arrayList != null)
                {
                    arrayList2.AddRange(arrayList);
                }
                else if (arrayList != null)
                {
                    arrayList2 = new ArrayList(arrayList);
                }
                BaseSet(key, arrayList2);
            }
        }
Example #3
0
        // Add the contents of another name/value collection to this collection.
        public void Add(NameValueCollection c)
        {
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            int       count = c.Count;
            int       posn;
            String    name;
            ArrayList strings;

            for (posn = 0; posn < count; ++posn)
            {
                name    = c.BaseGetKey(posn);
                strings = (ArrayList)(c.BaseGet(posn));
                foreach (String value in strings)
                {
                    Add(name, value);
                }
            }
        }
Example #4
0
		public void Add (NameValueCollection c)
		{
			if (this.IsReadOnly)
				throw new NotSupportedException ("Collection is read-only");
			if (c == null)
				throw new ArgumentNullException ("c");

// make sense - but it's not the exception thrown
//				throw new ArgumentNullException ();
			
			InvalidateCachedArrays ();
			int max = c.Count;
			for (int i=0; i < max; i++){
				string key = c.GetKey (i);
				ArrayList new_values = (ArrayList) c.BaseGet (i);
				ArrayList values = (ArrayList) BaseGet (key);
				if (values != null && new_values != null)
					values.AddRange (new_values);
				else if (new_values != null)
					values = new ArrayList (new_values);
				BaseSet (key, values);
			}
		}
	// Add the contents of another name/value collection to this collection.
	public void Add(NameValueCollection c)
			{
				if(c == null)
				{
					throw new ArgumentNullException("c");
				}
				int count = c.Count;
				int posn;
				String name;
				ArrayList strings;
				for(posn = 0; posn < count; ++posn)
				{
					name = c.BaseGetKey(posn);
					strings = (ArrayList)(c.BaseGet(posn));
					foreach(String value in strings)
					{
						Add(name, value);
					}
				}
			}