/// <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); } } }
/// <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); } } }
/// <summary> /// 设置禁用事件绑定 /// </summary> protected void SetDisableEvent() { _isDisableEvent = true; if (_itemEvent != null) { ItemEvent.Dispose(); _itemEvent = null; } if (_childrenEvent != null) { ChildrenEvent.Dispose(); _childrenEvent = null; } }
/// <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(); } }
/// <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); } } }