Exemplo n.º 1
0
        /// <summary>
        /// Creates the collection from cookie header.
        /// </summary>
        /// <param name="cookieHeader">The cookie header.</param>
        /// <returns></returns>
        public static HttpValueCollection CreateCollectionFromCookieHeader(string cookieHeader)
        {
            if (string.IsNullOrEmpty(cookieHeader))
            {
                return(new HttpValueCollection());
            }
            HttpValueCollection result = new HttpValueCollection();

            foreach (string entry in cookieHeader.Split(';'))
            {
                if (entry.Trim().Length == 0)
                {
                    continue;
                }
                string[] nameValue = entry.Split('=');
                if (nameValue.Length == 1)
                {
                    result[nameValue[0].Trim()] = string.Empty;
                }
                else
                {
                    result[nameValue[0].Trim()] = string.Join("=", nameValue, 1, nameValue.Length - 1);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the collection from URL encoded.
        /// </summary>
        /// <param name="urlEncoded">The URL encoded.</param>
        /// <returns></returns>
        public static HttpValueCollection CreateCollectionFromUrlEncoded(string urlEncoded)
        {
            if (string.IsNullOrEmpty(urlEncoded))
            {
                return(new HttpValueCollection());
            }
            HttpValueCollection result = new HttpValueCollection();

            foreach (string entry in urlEncoded.Split('&'))
            {
                if (entry.Trim().Length == 0)
                {
                    continue;
                }
                string[] nameValue = entry.Split('=');
                if (nameValue.Length == 1)
                {
                    result[HttpUtility.UrlDecode(nameValue[0])] = string.Empty;
                }
                else
                {
                    result[HttpUtility.UrlDecode(nameValue[0])] = HttpUtility.UrlDecode(nameValue[1]);
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the collection from XML node.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        public static HttpValueCollection CreateCollectionFromXmlNode(IXPathNavigable node)
        {
            HttpValueCollection result = new HttpValueCollection();

            if (node != null)
            {
                LoadCollectionFromXmlNode(result, node);
            }
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            HttpValueCollection collection = obj as HttpValueCollection;

            if (collection == null)
            {
                return(false);
            }
            return(collection.ToString() == ToString());
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpValueXPathNavigator"/> class.
 /// </summary>
 /// <param name="collection">The collection.</param>
 public HttpValueXPathNavigator(HttpValueCollection collection)
 {
     _Collection = collection;
 }