コード例 #1
0
ファイル: CookieCollection.cs プロジェクト: z77ma/runtime
        // If isStrict == false, assumes that incoming cookie is unique.
        // If isStrict == true, replace the cookie if found same with newest Variant.
        // Returns 1 if added, 0 if replaced or rejected.

        internal int InternalAdd(Cookie cookie, bool isStrict)
        {
            int ret = 1;

            if (isStrict)
            {
                int idx       = 0;
                int listCount = m_list.Count;
                for (int i = 0; i < listCount; i++)
                {
                    Cookie c = (Cookie)m_list[i] !;
                    if (CookieComparer.Equals(cookie, c))
                    {
                        ret = 0; // Will replace or reject

                        // Cookie2 spec requires that new Variant cookie overwrite the old one.
                        if (c !.Variant <= cookie.Variant)
                        {
                            m_list[idx] = cookie;
                        }
                        break;
                    }
                    ++idx;
                }
                if (idx == m_list.Count)
                {
                    m_list.Add(cookie);
                }
            }
            else
            {
                m_list.Add(cookie);
            }
            if (cookie.Version != Cookie.MaxSupportedVersion)
            {
                m_has_other_versions = true;
            }
            return(ret);
        }