/// <summary>
        /// 根据Cache项得到通知的Key
        /// </summary>
        /// <returns></returns>
        protected CacheNotifyKey GetNotifyKey()
        {
            CacheNotifyKey key = new CacheNotifyKey();
            KeyValuePair <object, object> kp = this.CacheItem.GetKeyValue();

            key.CacheQueueType = this.CacheItem.Queue.GetType();
            key.CacheKey       = kp.Key;

            return(key);
        }
		/// <summary>
		/// 根据Cache项得到通知的Key
		/// </summary>
		/// <returns></returns>
		protected CacheNotifyKey GetNotifyKey()
		{
			CacheNotifyKey key = new CacheNotifyKey();
			KeyValuePair<object, object> kp = this.CacheItem.GetKeyValue();

			key.CacheQueueType = this.CacheItem.Queue.GetType();
			key.CacheKey = kp.Key;

			return key;
		}
        /// <summary>
        /// 当CacheItem加入到Cache队列中时
        /// </summary>
        protected internal override void CacheItemBinded()
        {
            CacheNotifyKey           key     = GetNotifyKey();
            NotifierCacheMonitorBase monitor = GetMonitor();

            lock (monitor.CacheItems)
            {
                monitor.CacheItems[key] = this;
            }

            monitor.EnsureMonitorNotifyThread();
        }
        /// <summary>
        /// 处理Cache项的改变
        /// </summary>
        /// <param name="data"></param>
        protected void DoCacheChanged(CacheNotifyData data)
        {
            DependencyBase dependency;

            if (data.NotifyType == CacheNotifyType.Clear)
            {
                //清除所有UDP缓存相关的缓存队列
                CacheQueueBase needToClearQueue = null;

                lock (this.CacheItems)
                {
                    foreach (KeyValuePair <CacheNotifyKey, DependencyBase> kp in this.CacheItems)
                    {
                        if (kp.Key.CacheQueueType == data.CacheQueueType)
                        {
                            needToClearQueue = kp.Value.CacheItem.Queue;
                        }
                    }
                }

                if (needToClearQueue != null)
                {
                    needToClearQueue.Clear();
                }
            }
            else
            {
                CacheNotifyKey key = new CacheNotifyKey();

                key.CacheKey       = data.CacheKey;
                key.CacheQueueType = data.CacheQueueType;

                lock (this.CacheItems)
                {
                    if (this.CacheItems.TryGetValue(key, out dependency))
                    {
                        switch (data.NotifyType)
                        {
                        case CacheNotifyType.Invalid:
                            dependency.SetChanged();
                            this.CacheItems.Remove(key);
                            break;

                        case CacheNotifyType.Update:
                            dependency.CacheItem.SetValue(data.CacheData);
                            break;
                        }
                    }
                }
            }
        }
		/// <summary>
		/// 处理Cache项的改变
		/// </summary>
		/// <param name="data"></param>
		protected void DoCacheChanged(CacheNotifyData data)
		{
			DependencyBase dependency;

			if (data.NotifyType == CacheNotifyType.Clear)
			{
				//清除所有UDP缓存相关的缓存队列
				CacheQueueBase needToClearQueue = null;

				lock (this.CacheItems)
				{
					foreach (KeyValuePair<CacheNotifyKey, DependencyBase> kp in this.CacheItems)
					{
						if (kp.Key.CacheQueueType == data.CacheQueueType)
						{
							needToClearQueue = kp.Value.CacheItem.Queue;
						}
					}
				}

				if (needToClearQueue != null)
					needToClearQueue.Clear();
			}
			else
			{
				CacheNotifyKey key = new CacheNotifyKey();

				key.CacheKey = data.CacheKey;
				key.CacheQueueType = data.CacheQueueType;

				lock (this.CacheItems)
				{
					if (this.CacheItems.TryGetValue(key, out dependency))
					{
						switch (data.NotifyType)
						{
							case CacheNotifyType.Invalid:
								dependency.SetChanged();
								this.CacheItems.Remove(key);
								break;
							case CacheNotifyType.Update:
								dependency.CacheItem.SetValue(data.CacheData);
								break;
						}
					}
				}
			}
		}
        /// <summary>
        /// 释放资源
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                CacheNotifyKey           key     = GetNotifyKey();
                NotifierCacheMonitorBase monitor = GetMonitor();

                lock (monitor.CacheItems)
                {
                    if (monitor.CacheItems.ContainsKey(key))
                    {
                        monitor.CacheItems.Remove(key);
                    }
                }
            }

            base.Dispose(disposing);
        }