Ejemplo n.º 1
0
        /// <summary>
        /// Creates a copy of the current instance that is read-only.
        /// <seealso cref="IsReadOnly"/>
        /// </summary>
        /// <returns>A read-only instance.</returns>
        public NameValueCollectionEx ToReadOnly()
        {
            var result = new NameValueCollectionEx();

            result.Add(this);
            result.IsReadOnly = true;
            return(result);
        }
        /// <summary>
        /// Creates a copy of the current instance that is read-only.
        /// </summary>
        /// <param name="value">Specifies the collection to convert to read-only.</param>
        /// <returns>A read-only instance.</returns>
        public static NameValueCollection ToReadOnly(this NameValueCollection value)
        {
            Contract.Requires <ArgumentNullException>(value != null, "value is null.");

            var result = new NameValueCollectionEx();

            result.Add(value);
            return(result.ToReadOnly());
        }