Пример #1
0
        public static string ToUrlFormat(this IDictionary <string, string> dictionary)
        {
            SeparatedStringBuilder stringBuilder = new SeparatedStringBuilder("&");

            foreach (KeyValuePair <string, string> parameter in dictionary)
            {
                stringBuilder.AppendFormatWithSeparator("{0}={1}", parameter.Key, parameter.Value);
            }

            return(stringBuilder.ToString());
        }
Пример #2
0
        private string GetPageHeaders(WebResponse response)
        {
            SeparatedStringBuilder headersBuilder = new SeparatedStringBuilder("\r\n");

            for (int i = 0; i < response.Headers.Count; i++)
            {
                string key = response.Headers.GetKey(i);
                SeparatedStringBuilder values = new SeparatedStringBuilder(",", response.Headers.GetValues(i));
                headersBuilder.AppendFormatWithSeparator("{0}: {1}", key, values.ToString());
            }

            return(headersBuilder.ToString());
        }
Пример #3
0
        public static string ToFormattedString(this IDictionary <string, string> dictionary)
        {
            SeparatedStringBuilder stringBuilder = new SeparatedStringBuilder(" AND ");

            foreach (KeyValuePair <string, string> parameter in dictionary)
            {
                if (!string.IsNullOrWhiteSpace(parameter.Value))
                {
                    stringBuilder.AppendFormatWithSeparator("{0} = '{1}'", parameter.Key, parameter.Value);
                }
            }

            return(stringBuilder.ToString());
        }