本文整理汇总了C#中System.Net.CookieCollection.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# CookieCollection.RemoveAt方法的具体用法?C# CookieCollection.RemoveAt怎么用?C# CookieCollection.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.CookieCollection
的用法示例。
在下文中一共展示了CookieCollection.RemoveAt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpireCollection
private int ExpireCollection(CookieCollection cc)
{
int count = cc.Count;
int idx = count - 1;
lock (cc)
{
while (idx >= 0)
{
Cookie cookie = cc[idx];
if (cookie.Expired)
{
cc.RemoveAt(idx);
}
idx--;
}
}
return (count - cc.Count);
}
示例2: MergeUpdateCollections
private void MergeUpdateCollections(CookieCollection destination, CookieCollection source, int port, bool isSecure, bool isPlainOnly)
{
lock (source)
{
for (int i = 0; i < source.Count; i++)
{
bool flag = false;
Cookie cookie = source[i];
if (cookie.Expired)
{
source.RemoveAt(i);
this.m_count--;
i--;
continue;
}
if (!isPlainOnly || (cookie.Variant == CookieVariant.Plain))
{
if (cookie.PortList != null)
{
foreach (int num2 in cookie.PortList)
{
if (num2 == port)
{
flag = true;
break;
}
}
}
else
{
flag = true;
}
}
if (cookie.Secure && !isSecure)
{
flag = false;
}
if (flag)
{
destination.InternalAdd(cookie, false);
}
}
}
}
示例3: MergeUpdateCollections
private void MergeUpdateCollections(CookieCollection destination, CookieCollection source, int port, bool isSecure, bool isPlainOnly)
{
lock (source)
{
// Cannot use foreach as we going update 'source'
for (int idx = 0; idx < source.Count; ++idx)
{
bool to_add = false;
Cookie cookie = source[idx];
if (cookie.Expired)
{
// If expired, remove from container and don't add to the destination
source.RemoveAt(idx);
--_count;
--idx;
}
else
{
// Add only if port does match to this request URI
// or was not present in the original response.
if (isPlainOnly && cookie.Variant != CookieVariant.Plain)
{
; // Don't add
}
else if (cookie.PortList != null)
{
foreach (int p in cookie.PortList)
{
if (p == port)
{
to_add = true;
break;
}
}
}
else
{
// It was implicit Port, always OK to add.
to_add = true;
}
// Refuse to add a secure cookie into an 'unsecure' destination
if (cookie.Secure && !isSecure)
{
to_add = false;
}
if (to_add)
{
// In 'source' are already orederd.
// If two same cookies come from different 'source' then they
// will follow (not replace) each other.
destination.InternalAdd(cookie, false);
}
}
}
}
}
示例4: ExpireCollection
// Return number of cookies removed from the collection.
private int ExpireCollection(CookieCollection cc)
{
lock (cc)
{
int oldCount = cc.Count;
int idx = oldCount - 1;
// Cannot use enumerator as we are going to alter collection.
while (idx >= 0)
{
Cookie cookie = cc[idx];
if (cookie.Expired)
{
cc.RemoveAt(idx);
}
--idx;
}
return oldCount - cc.Count;
}
}
示例5: MergeUpdateCollections
private void MergeUpdateCollections(CookieCollection destination, CookieCollection source, int port, bool isSecure, bool isPlainOnly)
{
lock (source)
{
for (int local_0 = 0; local_0 < source.Count; ++local_0)
{
bool local_1 = false;
Cookie local_2 = source[local_0];
if (local_2.Expired)
{
source.RemoveAt(local_0);
--this.m_count;
--local_0;
}
else
{
if (!isPlainOnly || local_2.Variant == CookieVariant.Plain)
{
if (local_2.PortList != null)
{
foreach (int item_0 in local_2.PortList)
{
if (item_0 == port)
{
local_1 = true;
break;
}
}
}
else
local_1 = true;
}
if (local_2.Secure && !isSecure)
local_1 = false;
if (local_1)
destination.InternalAdd(local_2, false);
}
}
}
}
示例6: ExpireCollection
private int ExpireCollection(CookieCollection cc)
{
int count = cc.Count;
int idx = count - 1;
lock (cc)
{
for (; idx >= 0; --idx)
{
if (cc[idx].Expired)
cc.RemoveAt(idx);
}
}
return count - cc.Count;
}
示例7: ExpireCollection
//return number of cookies removed from the collection
private int ExpireCollection(CookieCollection cc) {
int oldCount = cc.Count;
int idx = oldCount-1;
// minor optimization by caching Now
DateTime now = DateTime.Now;
lock (cc) {
//Cannot use enumerator as we are going to alter collection
while (idx >= 0) {
Cookie cookie = cc[idx];
if (cookie.Expires <= now && cookie.Expires != DateTime.MinValue) {
cc.RemoveAt(idx);
}
--idx;
}
}
return oldCount - cc.Count;
}