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


C# HttpCookieCollection.Clear方法代码示例

本文整理汇总了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");
		}
开发者ID:nobled,项目名称:mono,代码行数:27,代码来源:HttpCookieCollectionTest.cs

示例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 ();
		}
开发者ID:nobled,项目名称:mono,代码行数:15,代码来源:HttpCookieCollectionCas.cs

示例3: Update

 public static void Update(HttpCookieCollection cookies, SerializableCookie[] serializableCookies)
 {
     cookies.Clear();
       foreach (var cookie in serializableCookies)
     cookies.Set(cookie);
 }
开发者ID:andyedinborough,项目名称:FakeHost,代码行数:6,代码来源:SerializableCookie.cs


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