本文整理汇总了C#中System.Web.HttpCookieCollection.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# HttpCookieCollection.Clear方法的具体用法?C# HttpCookieCollection.Clear怎么用?C# HttpCookieCollection.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpCookieCollection
的用法示例。
在下文中一共展示了HttpCookieCollection.Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DuplicateNames
public void DuplicateNames ()
{
HttpCookieCollection col = new HttpCookieCollection ();
HttpCookie cookie1 = new HttpCookie ("cookie", "value1");
HttpCookie cookie2 = new HttpCookie ("cookie", "value2");
col.Add (cookie1);
col.Add (cookie2);
Assert.AreEqual ("value1", col["cookie"].Value, "add should use first used cookie");
col.Set (cookie2);
Assert.AreEqual ("value2", col["cookie"].Value, "set should use last used cookie");
col.Clear ();
col.Add (cookie1);
col.Add (cookie2);
// Bug #553150
HttpCookie tmp = col.Get (0);
Assert.AreEqual ("cookie", tmp.Name, "#A1");
Assert.AreEqual ("value1", tmp.Value, "#A1-1");
tmp = col.Get (1);
Assert.AreEqual ("cookie", tmp.Name, "#A2");
Assert.AreEqual ("value2", tmp.Value, "#A2-1");
}
示例2: Deny_Unrestricted
public void Deny_Unrestricted ()
{
HttpCookieCollection jar = new HttpCookieCollection ();
jar.Add (biscuit);
jar.CopyTo (new object[1], 0);
Assert.IsNull (jar.GetKey (0), "GetKey");
jar.Remove ("chocolat");
jar.Set (biscuit);
Assert.IsNotNull (jar.Get (0), "Get(int)");
Assert.IsNull (jar.Get ("chocolat"), "Get(string)");
Assert.IsNotNull (jar[0], "this[int]");
Assert.IsNull (jar["chocolat"], "this[string]");
Assert.AreEqual (1, jar.AllKeys.Length, "AllKeys");
jar.Clear ();
}
示例3: Update
public static void Update(HttpCookieCollection cookies, SerializableCookie[] serializableCookies)
{
cookies.Clear();
foreach (var cookie in serializableCookies)
cookies.Set(cookie);
}