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


C# WebHeaderCollection.GetValues方法代码示例

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


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

示例1: HttpRequestHeader_Get_Success

 public void HttpRequestHeader_Get_Success()
 {
     WebHeaderCollection w = new WebHeaderCollection();
     w.Add("header1", "value1");
     w.Add("header1", "value2");
     string[] values = w.GetValues(0);
     Assert.Equal("value1", values[0]);
     Assert.Equal("value2", values[1]);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:9,代码来源:WebHeaderCollectionTest.netstandard17.cs

示例2: GetValues_Int_Fail

        public void GetValues_Int_Fail()
        {
            WebHeaderCollection w = new WebHeaderCollection();
            w.Add("Accept", "text/plain");

            Assert.Throws<ArgumentOutOfRangeException>(() => w.GetValues(-1));
            Assert.Throws<ArgumentOutOfRangeException>(() => w.GetValues(42));
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:8,代码来源:WebHeaderCollectionTest.cs

示例3: GetValues_Int_Success

        public void GetValues_Int_Success()
        {
            string[] keys = { "Accept", "uPgRaDe", "Custom" };
            string[] values = { "text/plain, text/html", " HTTP/2.0 , SHTTP/1.3,  , RTA/x11 ", "\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\"" };
            WebHeaderCollection w = new WebHeaderCollection();

            for (int i = 0; i < keys.Length; ++i)
            {
                w.Add(keys[i], values[i]);
            }

            for (int i = 0; i < keys.Length; ++i)
            {
                string[] expected = new[] { values[i].Trim() };
                Assert.Equal(expected, w.GetValues(i));
            }
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:17,代码来源:WebHeaderCollectionTest.cs

示例4: GetValues_String_Success

 public void GetValues_String_Success(string header, string value, string[] expectedValues)
 {
     WebHeaderCollection w = new WebHeaderCollection();
     w.Add(header, value);
     string modifiedHeader = header.ToLowerInvariant(); // header should be case insensitive
     Assert.Equal(expectedValues, w.GetValues(modifiedHeader));
 }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:7,代码来源:WebHeaderCollectionTest.cs

示例5: GetNonExistent_ReturnsNull_Success

 public void GetNonExistent_ReturnsNull_Success()
 {
     WebHeaderCollection w = new WebHeaderCollection();
     Assert.Equal(0, w.Count);
     Assert.Null(w["name"]);
     Assert.Null(w.GetValues("name"));
 }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:7,代码来源:WebHeaderCollectionTest.cs

示例6: HttpRequestHeader_GetValues_Success

 public void HttpRequestHeader_GetValues_Success()
 {
     WebHeaderCollection w = new WebHeaderCollection();
     w.Add("header1", "value1");
     Assert.Equal("value1", w.GetValues("header1")[0]);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:6,代码来源:WebHeaderCollectionTest.netstandard17.cs

示例7: AddHeaderValues

        private static void AddHeaderValues(WebHeaderCollection source, int index, string header, HttpHeaders destination)
        {
            string[] values = source.GetValues(index);

            // Even though AddWithoutValidation() could throw FormatException for header values containing newline
            // chars that are not followed by whitespace chars, we don't need to catch that exception. Our header
            // values were returned by HttpWebResponse which is trusted to only return valid header values.
            if (values.Length == 1)
            {
                destination.AddWithoutValidation(header, values[0]);
            }
            else
            {
                for (int j = 0; j < values.Length; j++)
                {
                    destination.AddWithoutValidation(header, values[j]);
                }
            }
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:19,代码来源:HttpClientChannel.cs

示例8: TestWebHeaderCollectionGetValues

	public void TestWebHeaderCollectionGetValues()
	{
		WebHeaderCollection whc = new WebHeaderCollection();
		string[] strArray1;
		try
		{
			strArray1 = whc.GetValues(null);
			Fail("GetValues: failed to throw exception for null argument");
		}
		catch(ArgumentNullException)
		{
			// Ok
		}
		whc.Add("phony:junk");
		whc.Add("more", "stuff");
		string[] strArray = whc.GetValues("phony");
		if (strArray[0] != "junk")
			Fail("GetValues: returned incorrect data for 'phony:junk'");
		strArray1 = whc.GetValues("more");
		if (strArray1[0] != "stuff")
			Fail("GetValues: returned incorrect data for 'more:stuff'");
		string[] strArray2 = whc.GetValues("notThere");
		if (strArray2 != null)
			Fail("GetValues: did not return null for name:value not in collection");
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:25,代码来源:TestWebHeaderCollection.cs


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