示例#1
0
        private void ContentPrepareChange(object sender, ContentChangeEventArgs e)
        {
            var node = e.Content.OwnerNode as IGraphNode;

            if (node != null)
            {
                var visitor = new GraphVisitorBase();
                visitor.Visiting   += UnregisterNode;
                visitor.ShouldVisit = shouldRegisterNode;
                switch (e.ChangeType)
                {
                case ContentChangeType.ValueChange:
                    // The changed node itself is still valid, we don't want to unregister it
                    visitor.SkipRootNode = true;
                    visitor.Visit(node);
                    break;

                case ContentChangeType.CollectionRemove:
                    if (node.Content.IsReference && e.OldValue != null)
                    {
                        var removedNode = node.Content.Reference.AsEnumerable[e.Index].TargetNode;
                        if (removedNode != null)
                        {
                            visitor.Visit(removedNode);
                        }
                    }
                    break;
                }
            }

            PrepareChange?.Invoke(sender, new GraphContentChangeEventArgs(e));
        }
示例#2
0
        private void ContentPrepareChange(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())
                    {
                        UnregisterNode(child.Item1);
                    }
                    break;

                case ContentChangeType.CollectionRemove:
                    if (node.Content.IsReference && e.OldValue != null)
                    {
                        var removedNode = node.Content.Reference.AsEnumerable[e.Index].TargetNode;
                        if (removedNode != null)
                        {
                            foreach (var child in removedNode.GetAllChildNodes())
                            {
                                UnregisterNode(child.Item1);
                            }
                            UnregisterNode(removedNode);
                        }
                    }
                    break;
                }
            }

            PrepareChange?.Invoke(sender, new GraphContentChangeEventArgs(e, path));
        }
示例#3
0
        /// <summary>
        /// Raises the <see cref="Changing"/> 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 NotifyContentChanging(object index, ContentChangeType changeType, object oldValue, object newValue)
        {
            var args = new ContentChangeEventArgs(this, index, changeType, oldValue, newValue);

            PrepareChange?.Invoke(this, args);
            Changing?.Invoke(this, args);
        }
示例#4
0
        private void ContentPrepareChange(object sender, ContentChangeEventArgs e)
        {
            var node = e.Content.OwnerNode as IGraphNode;

            if (node != null)
            {
                foreach (var child in node.GetAllChildNodes())
                {
                    UnregisterNode(child);
                }
            }

            PrepareChange?.Invoke(sender, e);
        }
示例#5
0
        private void ContentPrepareChange(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())
                {
                    UnregisterNode(child.Item1);
                }
            }

            PrepareChange?.Invoke(sender, new GraphContentChangeEventArgs(e, path));
        }
示例#6
0
 protected void NotifyItemChanging(ItemChangeEventArgs args)
 {
     PrepareChange?.Invoke(this, args);
     ItemChanging?.Invoke(this, args);
 }
示例#7
0
 /// <summary>
 /// Raises the <see cref="ValueChanging"/> event with the given parameters.
 /// </summary>
 /// <param name="args">The arguments of the event.</param>
 protected void NotifyContentChanging(MemberNodeChangeEventArgs args)
 {
     PrepareChange?.Invoke(this, args);
     ValueChanging?.Invoke(this, args);
 }
示例#8
0
 /// <summary>
 /// Raises the <see cref="Changing"/> event with the given parameters.
 /// </summary>
 /// <param name="args">The arguments of the event.</param>
 protected void NotifyContentChanging(ContentChangeEventArgs args)
 {
     PrepareChange?.Invoke(this, args);
     Changing?.Invoke(this, args);
 }