/// <summary> /// Raises the <see cref="Changed"/> event with the given parameters. /// </summary> /// <param name="index">The index where the change occurred, if applicable. <c>null</c> otherwise.</param> /// <param name="changeType">The type of change that occurred.</param> /// <param name="oldValue">The old value of this content.</param> /// <param name="newValue">The new value of this content.</param> protected void NotifyContentChanged(object index, ContentChangeType changeType, object oldValue, object newValue) { var args = new ContentChangeEventArgs(this, index, changeType, oldValue, newValue); Changed?.Invoke(this, args); FinalizeChange?.Invoke(this, args); }
private void ContentFinalizeChange(object sender, ContentChangeEventArgs e) { var node = e.Content.OwnerNode as IGraphNode; if (node != null) { foreach (var child in node.GetAllChildNodes()) { RegisterNode(child); } } FinalizeChange?.Invoke(sender, e); }
private void ContentFinalizeChange(object sender, ContentChangeEventArgs e) { var node = e.Content.OwnerNode as IGraphNode; var path = GetPath(e.Content.OwnerNode); if (node != null) { foreach (var child in node.GetAllChildNodes(path)) { RegisterNode(child.Item1, child.Item2); } } FinalizeChange?.Invoke(sender, new GraphContentChangeEventArgs(e, path)); }
private void ContentFinalizeChange(object sender, ContentChangeEventArgs e) { var node = e.Content.OwnerNode as IGraphNode; var path = GetPath(e.Content.OwnerNode); if (node != null) { switch (e.ChangeType) { case ContentChangeType.ValueChange: foreach (var child in node.GetAllChildNodes(path)) { RegisterNode(child.Item1, child.Item2); } break; case ContentChangeType.CollectionAdd: if (node.Content.IsReference && e.NewValue != null) { var index = e.Index; IGraphNode addedNode; if (index != null) { addedNode = node.Content.Reference.AsEnumerable[e.Index].TargetNode; } else { var reference = node.Content.Reference.AsEnumerable.First(x => x.TargetNode.Content.Retrieve() == e.NewValue); index = reference.Index; addedNode = reference.TargetNode; } if (addedNode != null) { var addedNodePath = path?.Append(node, addedNode, GraphNodePath.ElementType.Index, index); RegisterNode(addedNode, addedNodePath); foreach (var child in addedNode.GetAllChildNodes()) { RegisterNode(child.Item1, child.Item2); } } } break; } } FinalizeChange?.Invoke(sender, new GraphContentChangeEventArgs(e, path)); }
private void ContentFinalizeChange(object sender, ContentChangeEventArgs e) { var node = e.Content.OwnerNode as IGraphNode; if (node != null) { var visitor = new GraphVisitorBase(); visitor.Visiting += (node1, path) => RegisterNode(node1); visitor.ShouldVisit = shouldRegisterNode; switch (e.ChangeType) { case ContentChangeType.ValueChange: // The changed node itself is still valid, we don't want to re-register it visitor.SkipRootNode = true; visitor.Visit(node); break; case ContentChangeType.CollectionAdd: if (node.Content.IsReference && e.NewValue != null) { IGraphNode addedNode; Index index; if (!e.Index.IsEmpty) { index = e.Index; addedNode = node.Content.Reference.AsEnumerable[e.Index].TargetNode; } else { var reference = node.Content.Reference.AsEnumerable.First(x => x.TargetNode.Content.Retrieve() == e.NewValue); index = reference.Index; addedNode = reference.TargetNode; } if (addedNode != null) { var path = new GraphNodePath(node).PushIndex(index); visitor.Visit(addedNode, path); } } break; } } FinalizeChange?.Invoke(sender, new GraphContentChangeEventArgs(e)); }
protected void NotifyItemChanged(ItemChangeEventArgs args) { ItemChanged?.Invoke(this, args); FinalizeChange?.Invoke(this, args); }
/// <summary> /// Raises the <see cref="ValueChanged"/> event with the given arguments. /// </summary> /// <param name="args">The arguments of the event.</param> protected void NotifyContentChanged(MemberNodeChangeEventArgs args) { ValueChanged?.Invoke(this, args); FinalizeChange?.Invoke(this, args); }
/// <summary> /// Raises the <see cref="Changed"/> event with the given arguments. /// </summary> /// <param name="args">The arguments of the event.</param> protected void NotifyContentChanged(ContentChangeEventArgs args) { Changed?.Invoke(this, args); FinalizeChange?.Invoke(this, args); }