当前位置: 首页>>代码示例>>C#>>正文


C# StringWriter.WriteFormat方法代码示例

本文整理汇总了C#中System.IO.StringWriter.WriteFormat方法的典型用法代码示例。如果您正苦于以下问题:C# StringWriter.WriteFormat方法的具体用法?C# StringWriter.WriteFormat怎么用?C# StringWriter.WriteFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.StringWriter的用法示例。


在下文中一共展示了StringWriter.WriteFormat方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ReadOnlyDictionaryOverloadTest

		public void ReadOnlyDictionaryOverloadTest()
		{
			var now = DateTime.Now;
			var keyValues = new Dictionary<string, object>()
			{
				{ "abc", 123 },
				{ "defgh", now },
				{ "ijkl", "XYZ" }
			};

			var tw = new StringWriter();
			tw.WriteFormat(
				"AAA{defgh}BBB{abc}CCC{ijkl}DDD",
				keyValues);

			Assert.AreEqual("AAA" + now + "BBB123CCCXYZDDD", tw.ToString());
		}
开发者ID:kekyo,项目名称:CenterCLR.NamingFormatter,代码行数:17,代码来源:WriteFormatTests.cs

示例3: DictionaryWithComparerOverloadTest

		public void DictionaryWithComparerOverloadTest()
		{
			var now = DateTime.Now;
			IDictionary<string, object> keyValues = new Dictionary<string, object>(
				StringComparer.InvariantCultureIgnoreCase)
			{
				{ "aBc", 123 },
				{ "dEFgh", now },
				{ "ijKl", "XYZ" }
			};

			var tw = new StringWriter();
			tw.WriteFormat(
				"AAA{Defgh}BBB{abC}CCC{IjkL}DDD",
				keyValues);

			Assert.AreEqual("AAA" + now + "BBB123CCCXYZDDD", tw.ToString());
		}
开发者ID:kekyo,项目名称:CenterCLR.NamingFormatter,代码行数:18,代码来源:WriteFormatTests.cs

示例4: EnumerableOverloadWithComparerTest

		public void EnumerableOverloadWithComparerTest()
		{
			var now = DateTime.Now;
			IEnumerable<KeyValuePair<string, object>> keyValues = new[]
			{
				new KeyValuePair<string, object>("aBc", 123),
				new KeyValuePair<string, object>("deFgH", now),
				new KeyValuePair<string, object>("iJKl", "XYZ"),
			};

			var tw = new StringWriter();
			tw.WriteFormat(
				"AAA{Defgh}BBB{abC}CCC{IjkL}DDD",
				StringComparer.InvariantCultureIgnoreCase,
				keyValues);

			Assert.AreEqual("AAA" + now + "BBB123CCCXYZDDD", tw.ToString());
		}
开发者ID:kekyo,项目名称:CenterCLR.NamingFormatter,代码行数:18,代码来源:WriteFormatTests.cs

示例5: EnumerableOverloadWithNoListTest

		public void EnumerableOverloadWithNoListTest()
		{
			var now = DateTime.Now;
			var keyValues = new[]
			{
				Tuple.Create("abc", (object)123),
				Tuple.Create("defgh", (object)now),
				Tuple.Create("ijkl", (object)"XYZ")
			}.
			Select(entry => new KeyValuePair<string, object>(entry.Item1, entry.Item2));

			var tw = new StringWriter();
			tw.WriteFormat(
				"AAA{defgh}BBB{abc}CCC{ijkl}DDD",
				keyValues);

			Assert.AreEqual("AAA" + now + "BBB123CCCXYZDDD", tw.ToString());
		}
开发者ID:kekyo,项目名称:CenterCLR.NamingFormatter,代码行数:18,代码来源:WriteFormatTests.cs

示例6: EnumerableOverloadWithArrayTest

		public void EnumerableOverloadWithArrayTest()
		{
			var now = DateTime.Now;
			IEnumerable<KeyValuePair<string, object>> keyValues = new[]
			{
				new KeyValuePair<string, object>("abc", 123),
				new KeyValuePair<string, object>("defgh", now),
				new KeyValuePair<string, object>("ijkl", "XYZ"),
			};

			var tw = new StringWriter();
			tw.WriteFormat(
				"AAA{defgh}BBB{abc}CCC{ijkl}DDD",
				keyValues);

			Assert.AreEqual("AAA" + now + "BBB123CCCXYZDDD", tw.ToString());
		}
开发者ID:kekyo,项目名称:CenterCLR.NamingFormatter,代码行数:17,代码来源:WriteFormatTests.cs

示例7: 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

示例8: 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

示例9: CreateBaseString

        private static string CreateBaseString(IEnumerable<char> url, IEnumerable<KeyValuePair<string, string>> requestParams, IEnumerable<KeyValuePair<string, string>> additional)
        {
            var combined = new SortedDictionary<string, string>();

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

            foreach (var p in additional) {
                combined.Add(p.Key, HttpEncoder.UrlEncode(p.Value));
            }

            var requestString = NormalizeRequestParameters(combined);

            using (var sw = new StringWriter()) {
                sw.Write("GET&");
                sw.WriteFormat("{0}&", HttpEncoder.UrlEncode(url));
                sw.WriteFormat("{0}", HttpEncoder.UrlEncode(requestString));
                return sw.ToString();
            }
        }
开发者ID:pravse,项目名称:CommSample,代码行数:21,代码来源:OAuthSignature.cs


注:本文中的System.IO.StringWriter.WriteFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。