public void Refresh() { if (Parent == null) { throw new InvalidOperationException("The node to refresh can be a root node."); } if (CombinedNodes.Any(x => x != null)) { var parent = (CombinedObservableNode)Parent; parent.NotifyPropertyChanging(Name); NotifyNodeUpdating(); if (AreCombinable(CombinedNodes)) { ClearCommands(); foreach (var child in Children.Cast <ObservableNode>().ToList()) { RemoveChild(child); } foreach (var modelNode in CombinedNodes.OfType <ObservableModelNode>()) { modelNode.ForceSetValue(modelNode.Value); } Initialize(); } NotifyNodeUpdated(); parent.NotifyPropertyChanged(Name); } }
public void Refresh() { if (Parent == null) { throw new InvalidOperationException("The node to refresh can be a root node."); } if (CombinedNodes.Any(x => x != null)) { var parent = (CombinedObservableNode)Parent; parent.NotifyPropertyChanging(Name); OnPropertyChanging(nameof(HasMultipleValues), nameof(IsPrimitive), nameof(HasList), nameof(HasDictionary)); if (AreCombinable(CombinedNodes)) { ClearCommands(); // Destroy all children and remove them Children.SelectDeep(x => x.Children).ForEach(x => x.Destroy()); foreach (var child in Children.Cast <ObservableNode>().ToList()) { RemoveChild(child); } Initialize(); } OnPropertyChanged(nameof(HasMultipleValues), nameof(IsPrimitive), nameof(HasList), nameof(HasDictionary)); parent.NotifyPropertyChanged(Name); } }
// TODO: do not remove from parent if we can avoid it public void Refresh() { if (Parent == null) { throw new InvalidOperationException("The node to refresh can be a root node."); } OnPropertyChanging("TypedValue", "HasMultipleValues", "IsPrimitive", "HasList", "HasDictionary"); if (CombinedNodes.Any(x => x != null)) { var parent = (CombinedObservableNode)Parent; parent.RemoveChild(this); if (AreCombinable(CombinedNodes)) { ClearCommands(); foreach (var child in Children.ToList()) { RemoveChild(child); } foreach (var modelNode in CombinedNodes.OfType <ObservableModelNode>()) { modelNode.Refresh(); } Initialize(true); } parent.AddChild(this); } OnPropertyChanged("TypedValue", "HasMultipleValues", "IsPrimitive", "HasList", "HasDictionary"); }
private bool ComputeHasMultipleValues() { if (IsPrimitive) { return(CombinedNodes.Any(x => !Equals(x.Value, CombinedNodes.First().Value))); } return(!AreAllValuesOfTheSameType(CombinedNodes.Select(x => x.Value))); }