Esempio n. 1
0
        private ChangeTrackerNode(object source, PropertiesSettings settings, bool isRoot)
        {
            this.refcountedRootChanges = RootChanges.GetOrCreate(source, settings, isRoot);
            var sourceChanges = this.refcountedRootChanges.Value;

            this.children = ChildNodes <ChangeTrackerNode> .Borrow();

            sourceChanges.PropertyChange += this.OnSourcePropertyChange;
            if (Is.NotifyingCollection(source))
            {
                this.ItemType = this.SourceList.GetType()
                                .GetItemType();
                sourceChanges.Add     += this.OnSourceAdd;
                sourceChanges.Remove  += this.OnSourceRemove;
                sourceChanges.Replace += this.OnSourceReplace;
                sourceChanges.Move    += this.OnSourceMove;
                sourceChanges.Reset   += this.OnSourceReset;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DirtyTrackerNode"/> class.
        /// A call to Initialize is needed after the ctor due to that we need to fetch child nodes and the graph can contain self
        /// </summary>
        private DirtyTrackerNode(IRefCounted <ReferencePair> refCountedPair, PropertiesSettings settings, bool isRoot)
        {
            this.refCountedPair = refCountedPair;
            var x = refCountedPair.Value.X;
            var y = refCountedPair.Value.Y;

            this.children = ChildNodes <DirtyTrackerNode> .Borrow();

            this.xNode = RootChanges.GetOrCreate(x, settings, isRoot);
            this.yNode = RootChanges.GetOrCreate(y, settings, isRoot);
            this.xNode.Value.PropertyChange += this.OnTrackedPropertyChange;
            this.yNode.Value.PropertyChange += this.OnTrackedPropertyChange;

            this.IsTrackingCollectionItems = Is.Enumerable(x, y) &&
                                             !settings.IsImmutable(x.GetType().GetItemType()) &&
                                             !settings.IsImmutable(y.GetType().GetItemType());

            if (Is.NotifyingCollections(x, y))
            {
                this.xNode.Value.Add     += this.OnTrackedAdd;
                this.xNode.Value.Remove  += this.OnTrackedRemove;
                this.xNode.Value.Replace += this.OnTrackedReplace;
                this.xNode.Value.Move    += this.OnTrackedMove;
                this.xNode.Value.Reset   += this.OnTrackedReset;

                this.yNode.Value.Add     += this.OnTrackedAdd;
                this.yNode.Value.Remove  += this.OnTrackedRemove;
                this.yNode.Value.Replace += this.OnTrackedReplace;
                this.yNode.Value.Move    += this.OnTrackedMove;
                this.yNode.Value.Reset   += this.OnTrackedReset;
            }

            var builder = DiffBuilder.GetOrCreate(x, y, settings);

            builder.Value.UpdateDiffs(x, y, settings);
            builder.Value.Refresh();
            this.refcountedDiffBuilder = builder;
            this.isDirty = !this.Builder.IsEmpty;
        }