本文整理汇总了C#中System.Web.HttpCookieCollection.GetKey方法的典型用法代码示例。如果您正苦于以下问题:C# HttpCookieCollection.GetKey方法的具体用法?C# HttpCookieCollection.GetKey怎么用?C# HttpCookieCollection.GetKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpCookieCollection
的用法示例。
在下文中一共展示了HttpCookieCollection.GetKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 ();
}
示例2: ValidateCookieCollection
private void ValidateCookieCollection(HttpCookieCollection cc) {
if (GranularValidationEnabled) {
// Granular request validation is enabled - validate collection entries only as they're accessed.
cc.EnableGranularValidation((key, value) => ValidateString(value, key, RequestValidationSource.Cookies));
}
else {
// Granular request validation is disabled - eagerly validate all collection entries.
int c = cc.Count;
for (int i = 0; i < c; i++) {
String key = cc.GetKey(i);
String val = cc.Get(i).Value;
if (!String.IsNullOrEmpty(val))
ValidateString(val, key, RequestValidationSource.Cookies);
}
}
}
示例3: ValidateCookieCollection
private void ValidateCookieCollection(HttpCookieCollection cc)
{
int count = cc.Count;
for (int i = 0; i < count; i++)
{
string key = cc.GetKey(i);
string str2 = cc.Get(i).Value;
if (!string.IsNullOrEmpty(str2))
{
this.ValidateString(str2, key, RequestValidationSource.Cookies);
}
}
}
示例4: GenerateCookieKeyPairs
/// <summary>
/// Servers the variables.
/// </summary>
/// <param name="collection">The collection.</param>
/// <returns></returns>
private static string GenerateCookieKeyPairs(HttpCookieCollection collection)
{
StringBuilder builder = new StringBuilder();
for (int index = 0; index < collection.Count; index++)
{
builder.AppendLine(string.Format("{0}:{1}", collection.GetKey(index), collection[index]));
}
return builder.ToString();
}