當前位置: 首頁>>代碼示例>>C#>>正文


C# StringWriter.TrimEnd方法代碼示例

本文整理匯總了C#中System.IO.StringWriter.TrimEnd方法的典型用法代碼示例。如果您正苦於以下問題:C# StringWriter.TrimEnd方法的具體用法?C# StringWriter.TrimEnd怎麽用?C# StringWriter.TrimEnd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.StringWriter的用法示例。


在下文中一共展示了StringWriter.TrimEnd方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ToHeaderString

        public static string ToHeaderString(this IList<EmailContact> contacts)
        {
            if (contacts.Count == 0) {
                return string.Empty;
            }

            using (var sw = new StringWriter()) {
                foreach (var contact in contacts) {
                    sw.WriteFormat("{0} <{1}>,", contact.Name, contact.Address);
                }
                sw.TrimEnd(',');
                return sw.ToString();
            }
        }
開發者ID:pravse,項目名稱:CommSample,代碼行數:14,代碼來源:EmailContactListExtensions.cs

示例2: FormatHeaderFieldsCommand

 private static string FormatHeaderFieldsCommand(IEnumerable<string> headers)
 {
     using (var sw = new StringWriter()) {
         sw.Write("HEADER.FIELDS (");
         foreach (var header in headers) {
             sw.Write(header);
             sw.Write(Characters.Space);
         }
         sw.TrimEnd(Characters.Space);
         sw.Write(")");
         return sw.ToString();
     }
 }
開發者ID:pravse,項目名稱:CommSample,代碼行數:13,代碼來源:ImapFetchQueryTranslator.cs

示例3: MakeRequest

        public WebResponse MakeRequest()
        {
            var requestParams = CreateOAuthRequestParams();

            if (_sign) {
                var signature = OAuthSignature.Create(this, requestParams);
                requestParams.Add(OAuthParameters.OAuthSignature, signature);
            }

            string url;
            using (var sw = new StringWriter()) {
                sw.Write(RequestEndpoint.AbsoluteUri);
                sw.Write("?");

                var sorted = new SortedDictionary<string, string>();

                foreach (var p in Parameters) {
                    sorted.Add(p.Key, p.Value);
                }

                foreach (var p in requestParams) {
                    sorted.Add(p.Key, p.Value);
                }

                foreach (var p in sorted) {
                    sw.Write("{0}={1}", p.Key, p.Key == OAuthParameters.OAuthVerifier
                                                   ? HttpEncoder.UrlEncode(p.Value) : p.Value);

                    sw.Write("&");
                }
                // if params have been written the last item will be a '&' else it will be a '?'.
                sw.TrimEnd('&');
                sw.TrimEnd('?');

                url = sw.ToString();
            }

            var request = (HttpWebRequest) WebRequest.Create(url);
            request.Accept = "*/*";
            request.Method = "GET";
            request.Headers.Add(HttpRequestHeader.Authorization, "OAuth");
            return request.GetResponse();
        }
開發者ID:pravse,項目名稱:CommSample,代碼行數:43,代碼來源:OAuthRequest.cs

示例4: GetAuthorizationUri

        public Uri GetAuthorizationUri()
        {
            string url;
            using (var sw = new StringWriter()) {
                sw.Write(RequestEndpoint.AbsoluteUri);
                if (Parameters.Count > 0) {
                    sw.Write("?");
                    foreach (var p in Parameters) {
                        sw.WriteFormat("{0}={1}&", p.Key, p.Value);
                    }
                    sw.TrimEnd('&');
                }
                url = sw.ToString();
            }

            var request = (HttpWebRequest) WebRequest.Create(url);
            request.Accept = "*/*";
            request.Method = "GET";

            var response = request.GetResponse();
            return response.ResponseUri;
        }
開發者ID:pravse,項目名稱:CommSample,代碼行數:22,代碼來源:OAuthRequest.cs

示例5: CreateXOAuthKey

        public string CreateXOAuthKey()
        {
            var requestParams = CreateOAuthRequestParams();

            if (_sign) {
                var signature = OAuthSignature.Create(this, requestParams);
                requestParams.Add(OAuthParameters.OAuthSignature, signature);
            }

            string token;
            using (var sw = new StringWriter()) {
                sw.Write("GET ");
                sw.Write(RequestEndpoint.AbsoluteUri);
                sw.Write(Characters.Space);

                var sorted = new SortedDictionary<string, string>();

                foreach (var p in Parameters) {
                    sorted.Add(p.Key, p.Value);
                }

                foreach (var p in requestParams) {
                    sorted.Add(p.Key, p.Value);
                }

                foreach (var p in sorted) {
                    sw.WriteFormat("{0}=\"{1}\",", p.Key, p.Value);
                }

                sw.TrimEnd(',');
                token = sw.ToString();
            }

            var bytes = Encoding.ASCII.GetBytes(token);
            return Convert.ToBase64String(bytes);
        }
開發者ID:pravse,項目名稱:CommSample,代碼行數:36,代碼來源:OAuthRequest.cs

示例6: NormalizeRequestParameters

        private static IEnumerable<char> NormalizeRequestParameters(IEnumerable<KeyValuePair<string, string>> @params)
        {
            using (var sw = new StringWriter()) {
                foreach (var pair in @params) {
                    sw.Write(pair.Key);
                    sw.Write("=");
                    sw.Write(pair.Value);
                    sw.Write("&");
                }

                sw.TrimEnd('&');
                return sw.ToString();
            }
        }
開發者ID:pravse,項目名稱:CommSample,代碼行數:14,代碼來源:OAuthSignature.cs


注:本文中的System.IO.StringWriter.TrimEnd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。