Esempio n. 1
0
        public string ToQueryStringFormat()
        {
            string[] excludedParameters =
            {
                Constants.RealmParameter,
                Constants.TokenSecretParameter
            };

            StringBuilder queryString = new StringBuilder();

            bool first = true;

            foreach (string key in this.parameters.Keys)
            {
                if (this.parameters[key] != null && Array.IndexOf <string>(excludedParameters, key) < 0)
                {
                    OAuthParameters.EncodeHeaderValue(queryString, key, this.parameters[key], first ? string.Empty : "&", false);
                    first = false;
                }
            }

            foreach (string key in this.AdditionalParameters.Keys)
            {
                foreach (string value in this.AdditionalParameters.GetValues(key))
                {
                    OAuthParameters.EncodeHeaderValue(queryString, key, value, first ? string.Empty : "&", false);
                    first = false;
                }
            }

            return(queryString.ToString());
        }
Esempio n. 2
0
        public string ToHeaderFormat()
        {
            string[] excludedParameters =
            {
                Constants.RealmParameter,
                Constants.TokenSecretParameter
            };

            StringBuilder refAuthHeader = new StringBuilder(Constants.OAuthAuthScheme);

            refAuthHeader.Append(" ");

            bool first = true;

            if (!String.IsNullOrEmpty(this.Realm))
            {
                OAuthParameters.EncodeHeaderValue(refAuthHeader, Constants.RealmParameter, this.Realm, first ? string.Empty : ", ", true);
                first = false;
            }

            foreach (string key in this.parameters.Keys)
            {
                if (this.parameters[key] != null && Array.IndexOf <string>(excludedParameters, key) < 0)
                {
                    OAuthParameters.EncodeHeaderValue(refAuthHeader, key, this.parameters[key], first ? string.Empty : ", ", true);
                    first = false;
                }
            }

            return(refAuthHeader.ToString());
        }