Esempio n. 1
0
        /// <summary>
        ///     Sorts a <see cref="WebParameterCollection" /> by name, and then value if equal.
        /// </summary>
        /// <param name="parameters">A collection of parameters to sort</param>
        /// <returns>A sorted parameter collection</returns>
        public static WebParameterCollection SortParametersExcludingSignature(WebParameterCollection parameters)
        {
            var copy       = new WebParameterCollection(parameters);
            var exclusions = copy.Where(n => n.Name.EqualsIgnoreCase("oauth_signature"));

            copy.RemoveAll(exclusions);

            copy.ForEach(
                p =>
            {
                p.Name  = UrlEncodeStrict(p.Name);
                p.Value = UrlEncodeStrict(p.Value);
            }
                );

            copy.Sort(
                (x, y) =>
            {
                var compareName = string.CompareOrdinal(x.Name, y.Name);

                return(compareName != 0
                        ? compareName
                        : string.CompareOrdinal(x.Value, y.Value));
            }
                );

            return(copy);
        }
Esempio n. 2
0
        /// <summary>
        /// Sorts a <see cref="WebParameterCollection"/> by name, and then value if equal.
        /// </summary>
        /// <param name="parameters">A collection of parameters to sort</param>
        /// <returns>A sorted parameter collection</returns>
        public static WebParameterCollection SortParametersExcludingSignature(WebParameterCollection parameters)
        {
            var copy       = new WebParameterCollection(parameters);
            var exclusions = copy.Where(n => n.Name.EqualsIgnoreCase("oauth_signature"));

            copy.RemoveAll(exclusions);
            copy.ForEach(p => p.Value = UrlEncodeStrict(p.Value));
            copy.Sort((x, y) => x.Name.Equals(y.Name) ? x.Value.CompareTo(y.Value) : x.Name.CompareTo(y.Name));
            return(copy);
        }
Esempio n. 3
0
        public static WebParameterCollection SortParametersExcludingSignature(WebParameterCollection parameters)
        {
            WebParameterCollection webParameterCollection = new WebParameterCollection(parameters);
            IEnumerable <WebPair>  parameters2            = from n in webParameterCollection
                                                            where n.Name.EqualsIgnoreCase("oauth_signature")
                                                            select n;

            webParameterCollection.RemoveAll(parameters2);
            webParameterCollection.ForEach(delegate(WebPair p)
            {
                p.Name  = UrlEncodeStrict(p.Name);
                p.Value = UrlEncodeStrict(p.Value);
            });
            webParameterCollection.Sort((WebPair x, WebPair y) => (string.CompareOrdinal(x.Name, y.Name) != 0) ? string.CompareOrdinal(x.Name, y.Name) : string.CompareOrdinal(x.Value, y.Value));
            return(webParameterCollection);
        }
Esempio n. 4
0
        /// <summary>
        /// Sorts a <see cref="WebParameterCollection"/> by name, and then value if equal.
        /// </summary>
        /// <param name="parameters">A collection of parameters to sort</param>
        /// <returns>A sorted parameter collection</returns>
        public static WebParameterCollection SortParametersExcludingSignature(WebParameterCollection parameters)
        {
            WebParameterCollection copy = new WebParameterCollection(parameters);
            IEnumerable<WebPair> exclusions = copy.Where(n => n.Name.EqualsIgnoreCase("oauth_signature"));

            copy.RemoveAll(exclusions);
            copy.ForEach(p =>
                         {
                             p.Name = UrlEncodeStrict(p.Name);
                             p.Value = UrlEncodeStrict(p.Value);
                         });
            copy.Sort((x, y) => string.CompareOrdinal(x.Name, y.Name) != 0
                ? string.CompareOrdinal(x.Name, y.Name)
                : string.CompareOrdinal(x.Value, y.Value));

            return copy;
        }
Esempio n. 5
0
        /// <summary>
        /// Sorts a <see cref="WebParameterCollection"/> by name, and then value if equal.
        /// </summary>
        /// <param name="parameters">A collection of parameters to sort</param>
        /// <returns>A sorted parameter collection</returns>
        public static WebParameterCollection SortParametersExcludingSignature(WebParameterCollection parameters)
        {
            var copy = new WebParameterCollection(parameters);
            var exclusions = copy.Where(n => n.Name.EqualsIgnoreCase("oauth_signature"));

            copy.RemoveAll(exclusions);
            copy.ForEach(p => p.Value = UrlEncodeStrict(p.Value));
            copy.Sort((x, y) => x.Name.Equals(y.Name) ? x.Value.CompareTo(y.Value) : x.Name.CompareTo(y.Name));
            return copy;
        }