Exemplo n.º 1
0
        /// <summary>
        /// 解绑设置时触发的事件
        /// </summary>
        /// <param name="listener"></param>
        public static void RemoveSetListner(string key, CookieSetListener listener)
        {
            List <CookieSetListener> listeners;

            if (!_setListeners.TryGetValue(key, out listeners))
            {
                listeners = _setListeners[key] = new List <CookieSetListener>();
            }
            if (listeners.Contains(listener))
            {
                listeners.Remove(listener);
            }
            else
            {
                throw new Exception("Not exist listener");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 绑定设置时触发的事件
        /// </summary>
        /// <param name="setter"></param>
        public static void AddSetListener(string key, CookieSetListener listener)
        {
            if (listener == null)
            {
                throw new NullReferenceException("CookieSetListener cannot be null!");
            }

            List <CookieSetListener> listeners;

            if (!_setListeners.TryGetValue(key, out listeners))
            {
                listeners = _setListeners[key] = new List <CookieSetListener>();
            }
            if (!listeners.Contains(listener))
            {
                listeners.Add(listener);
            }
            else
            {
                throw new Exception("Duplicated set listner");
            }
        }