private void RaisePropertyChanged <T>(DomainProperty property, T newValue, T oldValue) { if (IsConstructing) { return; //构造时,不触发任何事件 } if (!property.IsRegisteredChanged && this.PropertyChanged == null) { return; } var ctx = GetRunContext(property.RuntimeChangedId); if (!ctx.InCallBack) { var args = new DomainPropertyChangedEventArgs(property, newValue, oldValue); //先进行对象内部回调方法 ctx.InCallBack = true; property.ChangedChain.Invoke(this, args); args.NewValue = this.GetValue(property);//同步数据 ctx.InCallBack = false; //最后执行对象级别挂载的事件 if (this.PropertyChanged != null) { ctx.InCallBack = true; this.PropertyChanged(this, args); args.NewValue = this.GetValue(property);//同步数据 ctx.InCallBack = false; } } }
public void Invoke(DomainObject domainObject, DomainPropertyChangedEventArgs value) { //属性值被改变的行为链直接遍历所有方法并执行 foreach (var method in _methods) { method(domainObject, value); } }