当前位置: 首页>>代码示例>>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;未经允许,请勿转载。