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


C# CookieCollection.RemoveAt方法代码示例

本文整理汇总了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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:CookieContainer.cs

示例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);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:44,代码来源:CookieContainer.cs

示例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);
                        }
                    }
                }
            }
        }
开发者ID:rainersigwald,项目名称:corefx,代码行数:60,代码来源:CookieContainer.cs

示例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;
            }
        }
开发者ID:rainersigwald,项目名称:corefx,代码行数:21,代码来源:CookieContainer.cs

示例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);
       }
     }
       }
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:40,代码来源:CookieContainer.cs

示例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;
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:14,代码来源:CookieContainer.cs

示例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;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:21,代码来源:cookiecontainer.cs


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