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


C# MultipartContent.ReadAsStringAsync方法代码示例

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


在下文中一共展示了MultipartContent.ReadAsStringAsync方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add

        public void Add()
        {
            var m = new MultipartContent ("a", "b");

            var other = new MultipartContent ("2", "44");
            other.Headers.Expires = new DateTimeOffset (2020, 11, 30, 19, 55, 22, TimeSpan.Zero);
            m.Add (other);

            Assert.AreEqual ("multipart/a", m.Headers.ContentType.MediaType, "#1");
            Assert.AreEqual (114, m.Headers.ContentLength, "#2");
            Assert.AreEqual ("--b\r\nContent-Type: multipart/2; boundary=\"44\"\r\nExpires: Mon, 30 Nov 2020 19:55:22 GMT\r\n\r\n--44\r\n\r\n--44--\r\n\r\n--b--\r\n", m.ReadAsStringAsync ().Result, "#3");
            Assert.AreEqual (other, m.First (), "#4");
        }
开发者ID:RainsSoft,项目名称:dotnet-httpclient35,代码行数:13,代码来源:MultipartContentTest.cs

示例2: Add_2

        public void Add_2()
        {
            var m = new MultipartContent ("a", "X");

            var other = new MultipartContent ("2", "2a");
            m.Add (other);
            var other2 = new MultipartContent ("3", "3a");
            other2.Headers.Add ("9", "9n");
            m.Add (other2);

            Assert.AreEqual ("multipart/a", m.Headers.ContentType.MediaType, "#1");
            Assert.AreEqual (148, m.Headers.ContentLength, "#2");
            Assert.AreEqual ("--X\r\nContent-Type: multipart/2; boundary=\"2a\"\r\n\r\n--2a\r\n\r\n--2a--\r\n\r\n--X\r\nContent-Type: multipart/3; boundary=\"3a\"\r\n9: 9n\r\n\r\n--3a\r\n\r\n--3a--\r\n\r\n--X--\r\n",
                m.ReadAsStringAsync ().Result, "#3");
            Assert.AreEqual (other, m.First (), "#4");
        }
开发者ID:RainsSoft,项目名称:dotnet-httpclient35,代码行数:16,代码来源:MultipartContentTest.cs

示例3: Ctor

		public void Ctor ()
		{
			using (var m = new MultipartContent ("a", "b")) {
				m.Headers.Add ("extra", "value");
				Assert.AreEqual ("multipart/a", m.Headers.ContentType.MediaType, "#1");
				Assert.AreEqual (14, m.Headers.ContentLength, "#2");
				Assert.AreEqual ("--b\r\n\r\n--b--\r\n", m.ReadAsStringAsync ().Result, "#3");
			}

			using (var m = new MultipartContent ()) {
				Assert.AreEqual ("multipart/mixed", m.Headers.ContentType.MediaType, "#11");
				Assert.AreEqual (84, m.Headers.ContentLength, "#12");
			}

			using (var m = new MultipartContent ("ggg")) {
				Assert.AreEqual ("multipart/ggg", m.Headers.ContentType.MediaType, "#21");
				Assert.AreEqual (84, m.Headers.ContentLength, "#22");
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:19,代码来源:MultipartContentTest.cs

示例4: Add_Resursive

		public void Add_Resursive ()
		{
			var m = new MultipartContent ("1", "1a");

			var other = new MultipartContent ("2", "2a");
			m.Add (other);

			var other2 = new MultipartContent ("3", "3a");
			other.Add (other2);

			Assert.AreEqual ("multipart/1", m.Headers.ContentType.MediaType, "#1");
			Assert.AreEqual (136, m.Headers.ContentLength, "#2");
			Assert.AreEqual ("--1a\r\nContent-Type: multipart/2; boundary=\"2a\"\r\n\r\n--2a\r\nContent-Type: multipart/3; boundary=\"3a\"\r\n\r\n--3a\r\n\r\n--3a--\r\n\r\n--2a--\r\n\r\n--1a--\r\n",
				m.ReadAsStringAsync ().Result, "#3");
			Assert.AreEqual (other, m.First (), "#4");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:16,代码来源:MultipartContentTest.cs

示例5: ReadAsStringAsync_TwoSubContents_MatchesExpected

        public async Task ReadAsStringAsync_TwoSubContents_MatchesExpected()
        {
            var mc = new MultipartContent("someSubtype", "theBoundary");
            mc.Add(new ByteArrayContent(Encoding.UTF8.GetBytes("This is a ByteArrayContent")));
            mc.Add(new StringContent("This is a StringContent"));

            Assert.Equal(
                "--theBoundary\r\n" +
                "\r\n" +
                "This is a ByteArrayContent\r\n" +
                "--theBoundary\r\n" +
                "Content-Type: text/plain; charset=utf-8\r\n" +
                "\r\n" +
                "This is a StringContent\r\n" +
                "--theBoundary--\r\n",
                await mc.ReadAsStringAsync());
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:17,代码来源:MultipartContentTest.cs

示例6: ReadAsStringAsync_OneSubContentWithHeaders_MatchesExpected

        public async Task ReadAsStringAsync_OneSubContentWithHeaders_MatchesExpected()
        {
            var subContent = new ByteArrayContent(Encoding.UTF8.GetBytes("This is a ByteArrayContent"));
            subContent.Headers.Add("someHeaderName", "andSomeHeaderValue");
            subContent.Headers.Add("someOtherHeaderName", new[] { "withNotOne", "ButTwoValues" });
            subContent.Headers.Add("oneMoreHeader", new[] { "withNotOne", "AndNotTwo", "butThreeValues" });

            var mc = new MultipartContent("someSubtype", "theBoundary");
            mc.Add(subContent);

            Assert.Equal(
                "--theBoundary\r\n" +
                "someHeaderName: andSomeHeaderValue\r\n" +
                "someOtherHeaderName: withNotOne, ButTwoValues\r\n" +
                "oneMoreHeader: withNotOne, AndNotTwo, butThreeValues\r\n" +
                "\r\n" +
                "This is a ByteArrayContent\r\n" +
                "--theBoundary--\r\n", 
                await mc.ReadAsStringAsync());
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:20,代码来源:MultipartContentTest.cs

示例7: ReadAsStringAsync_NoSubContent_MatchesExpected

        public async Task ReadAsStringAsync_NoSubContent_MatchesExpected()
        {
            var mc = new MultipartContent("someSubtype", "theBoundary");

            Assert.Equal(
                "--theBoundary\r\n" +
                "\r\n" +
                "--theBoundary--\r\n", 
                await mc.ReadAsStringAsync());
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:10,代码来源:MultipartContentTest.cs


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