예제 #1
0
 /// <summary>
 /// 移除子对象监听
 /// </summary>
 internal override void RemoveChildrenListener(object changeEvent)
 {
     if (!_isDisableEvent && ChildrenEvent != null && changeEvent is IItemChangeEvent)
     {
         var child = (IItemChangeEvent)changeEvent;
         ChildrenEvent.RemoveItemEvent(child.UnChangeNotify);
         var e = child.ItemEvent;
         if (e != null)
         {
             e.RemoveItemEvent(NotifyByChildren);
         }
     }
 }
예제 #2
0
 /// <summary>
 /// 添加子对象监听
 /// </summary>
 public override void AddChildrenListener(object changeEvent)
 {
     if (!_isDisableEvent && ChildrenEvent != null && changeEvent is IItemChangeEvent)
     {
         var child = (IItemChangeEvent)changeEvent;
         ChildrenEvent.AddSingleItemEvent(child.UnChangeNotify);
         var e = child.ItemEvent;
         if (e != null)
         {
             e.AddSingleItemEvent(NotifyByChildren);
         }
     }
 }
예제 #3
0
 /// <summary>
 /// 设置禁用事件绑定
 /// </summary>
 protected void SetDisableEvent()
 {
     _isDisableEvent = true;
     if (_itemEvent != null)
     {
         ItemEvent.Dispose();
         _itemEvent = null;
     }
     if (_childrenEvent != null)
     {
         ChildrenEvent.Dispose();
         _childrenEvent = null;
     }
 }
예제 #4
0
 /// <summary>
 /// 触发UnChange事件通知
 /// </summary>
 internal override void UnChangeNotify(object sender, CacheItemEventArgs eventArgs)
 {
     if (ChildrenEvent != null)
     {
         ChildrenEvent.NotifyAll(sender, eventArgs);
     }
     if (!eventArgs.HasChanged)
     {
         _hasChanged = false;
     }
     if (eventArgs.ChangeType == CacheItemChangeType.DisableEvent)
     {
         SetDisableEvent();
     }
 }
예제 #5
0
 /// <summary>
 /// 添加子对象监听
 /// </summary>
 public override void AddChildrenListener(object changeEvent)
 {
     if (!_isDisableEvent && ChildrenEvent != null && changeEvent is IItemChangeEvent)
     {
         var child = (IItemChangeEvent)changeEvent;
         //注册多个子类的事件
         ChildrenEvent.AddSingleItemEvent(child.UnChangeNotify, null);
         var e = child.ItemEvent;
         if (e != null)
         {
             //注册父亲类单一事件
             e.AddSingleItemEvent(NotifyByChildren, this);
         }
     }
 }