Beispiel #1
0
 public void UnRegisterChangedAction(string origin, params Action[] target_action)
 {
     if (PropertyRelations.TryGetValue(origin, out var rel))
     {
         rel.RelatedChangedActions.RemoveWhere(x => target_action.Contains(x));
     }
 }
Beispiel #2
0
 public void UnRegisterRelationProperty(string origin, NotifyBase target_owner, params string[] target_prop)
 {
     if (PropertyRelations.TryGetValue(origin, out var rel))
     {
         rel.RelatedProps.RemoveWhere(x => x.Owner == target_owner && target_prop.Contains(x.PropertyName));
     }
 }
Beispiel #3
0
 public void RegisterChangedAction(string origin, params Action[] target_action)
 {
     if (!PropertyRelations.TryGetValue(origin, out var rel))
     {
         PropertyRelations[origin] = rel = new PropertyRelation();
     }
     foreach (var action in target_action)
     {
         if (!rel.RelatedChangedActions.Contains(action))
         {
             rel.RelatedChangedActions.Add(action);
         }
     }
 }
Beispiel #4
0
 public void RegisterRelationProperty(string origin, NotifyBase target_owner, params string[] target_prop)
 {
     if (!PropertyRelations.TryGetValue(origin, out var rel))
     {
         PropertyRelations[origin] = rel = new PropertyRelation();
     }
     foreach (var prop in target_prop)
     {
         var desc = new NotifyDescriptor(target_owner, prop);
         if (!rel.RelatedProps.Contains(desc))
         {
             rel.RelatedProps.Add(desc);
         }
     }
 }
Beispiel #5
0
 private void NotifyBase_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (PropertyRelations.TryGetValue(e.PropertyName, out var rel))
     {
         //notify all relations
         //execute all changed actions
         foreach (var item in rel.RelatedProps)
         {
             item.RaiseChanged();
         }
         foreach (var item in rel.RelatedChangedActions)
         {
             item?.Invoke();
         }
     }
 }