Ejemplo n.º 1
0
        public static WebParameterCollection SortParametersExcludingSignature(WebParameterCollection parameters)
        {
            WebParameterCollection     webParameterCollection = new WebParameterCollection(parameters);
            IEnumerable <WebParameter> parameters2            = webParameterCollection.Where((WebParameter n) => OAuthTools.EqualsIgnoreCase(n.Name, "oauth_signature"));

            webParameterCollection.RemoveAll(parameters2);
            foreach (WebParameter webParameter in webParameterCollection)
            {
                webParameter.Value = OAuthTools.UrlEncodeStrict(webParameter.Value);
            }
            webParameterCollection.Sort((WebParameter x, WebParameter y) => (!x.Name.Equals(y.Name)) ? x.Name.CompareTo(y.Name) : x.Value.CompareTo(y.Value));
            return(webParameterCollection);
        }
Ejemplo 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 => EqualsIgnoreCase(n.Name, "oauth_signature"));

            copy.RemoveAll(exclusions);

            foreach (var parameter in copy)
            {
                parameter.Value = UrlEncodeStrict(parameter.Value);
            }

            copy.Sort((x, y) => x.Name.Equals(y.Name) ? x.Value.CompareTo(y.Value) : x.Name.CompareTo(y.Name));
            return(copy);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sorts a <see cref="T:OAuth.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     source      = new WebParameterCollection((IEnumerable <WebParameter>)parameters);
            IEnumerable <WebParameter> parameters1 = source.Where <WebParameter>((Func <WebParameter, bool>)(n => OAuthTools.EqualsIgnoreCase(n.Name, "oauth_signature")));

            source.RemoveAll(parameters1);
            foreach (WebParameter webParameter in source)
            {
                webParameter.Value = OAuthTools.UrlEncodeStrict(webParameter.Value);
            }
            source.Sort((Comparison <WebParameter>)((x, y) =>
            {
                if (!x.Name.Equals(y.Name))
                {
                    return(x.Name.CompareTo(y.Name));
                }
                return(x.Value.CompareTo(y.Value));
            }));
            return(source);
        }