本文整理汇总了C#中HttpHeaders.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# HttpHeaders.TryGetValue方法的具体用法?C# HttpHeaders.TryGetValue怎么用?C# HttpHeaders.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.TryGetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSetValueNullRemovesKey
public void TestSetValueNullRemovesKey()
{
string dummy = null;
HttpHeaders headers = new HttpHeaders ();
headers.SetHeader ("Foo", "Bar");
Assert.AreEqual ("Bar", headers ["Foo"], "a1");
headers.SetHeader ("Foo", null);
Assert.IsFalse (headers.TryGetValue ("Foo", out dummy), "a2");
Assert.AreEqual (0, headers.Count, "a3");
}
示例2: TestSetContentLengthPropertyNegative
public void TestSetContentLengthPropertyNegative()
{
string dummy = null;
HttpHeaders headers = new HttpHeaders ();
Should.Throw<ArgumentException> (() => headers.ContentLength = -1, "a1");
Assert.IsNull (headers.ContentLength, "a2");
Assert.IsFalse (headers.TryGetValue ("Content-Length", out dummy), "a3");
Assert.IsNull (dummy, "a4");
}
示例3: TestSetContentLengthPropertyNull
public void TestSetContentLengthPropertyNull()
{
string dummy = null;
HttpHeaders headers = new HttpHeaders ();
headers.ContentLength = 100;
Assert.AreEqual (100, headers.ContentLength, "a1");
headers.ContentLength = null;
Assert.IsNull (headers.ContentLength, "a2");
Assert.IsFalse (headers.TryGetValue ("Content-Length", out dummy), "a3");
Assert.IsNull (dummy, "a4");
}
示例4: TestSetContentLengthProperty
public void TestSetContentLengthProperty()
{
string cl;
HttpHeaders headers = new HttpHeaders ();
headers.ContentLength = 10;
Assert.AreEqual (10, headers.ContentLength, "a1");
Assert.IsTrue (headers.TryGetValue ("Content-Length", out cl), "a2");
Assert.AreEqual ("10", cl, "a3");
headers.ContentLength = 100;
Assert.AreEqual (100, headers.ContentLength, "a4");
Assert.IsTrue (headers.TryGetValue ("Content-Length", out cl), "a5");
Assert.AreEqual ("100", cl, "a6");
headers.ContentLength = 0;
Assert.AreEqual (0, headers.ContentLength, "a7");
Assert.IsTrue (headers.TryGetValue ("Content-Length", out cl), "a8");
Assert.AreEqual ("0", cl, "a9");
}