public void Dispose()
 {
     this.dirtyTrackerNode.Value.Changed -= this.OnDirtyTrackerNodeChanged;
     this.dirtyTrackerNode.Dispose();
     this.borrowedQueue.Dispose();
     this.processingNode = null;
 }
            public void ReturnsDifferentForDifferentSettings()
            {
                var x = new WithSimpleProperties {
                    Value = 1, Time = DateTime.MinValue
                };
                var y = new WithSimpleProperties {
                    Value = 1, Time = DateTime.MinValue
                };
                var t1 = DirtyTrackerNode.GetOrCreate(x, y, PropertiesSettings.GetOrCreate(ReferenceHandling.Structural), true);
                var t2 = DirtyTrackerNode.GetOrCreate(x, y, PropertiesSettings.GetOrCreate(ReferenceHandling.References), true);

                Assert.AreNotSame(t1, t2);
            }
            public void ReturnsDifferentForDifferentPairs()
            {
                var x = new WithSimpleProperties {
                    Value = 1, Time = DateTime.MinValue
                };
                var y = new WithSimpleProperties {
                    Value = 1, Time = DateTime.MinValue
                };
                var settings = PropertiesSettings.GetOrCreate(ReferenceHandling.Structural);

                using (var t1 = DirtyTrackerNode.GetOrCreate(x, y, settings, isRoot: true))
                {
                    using (var t2 = DirtyTrackerNode.GetOrCreate(y, x, settings, isRoot: true))
                    {
                        Assert.AreNotSame(t1, t2);
                    }
                }
            }
            public void ReturnsSameWhileAlive()
            {
                var x        = new WithSimpleProperties();
                var y        = new WithSimpleProperties();
                var settings = PropertiesSettings.GetOrCreate(ReferenceHandling.Structural);
                var t1       = DirtyTrackerNode.GetOrCreate(x, y, settings, true);
                var t2       = DirtyTrackerNode.GetOrCreate(x, y, settings, true);

                Assert.AreSame(t1, t2);
                t1.Dispose();
                var t3 = DirtyTrackerNode.GetOrCreate(x, y, settings, true);

                Assert.AreSame(t1, t3);
                t2.Dispose();
                t3.Dispose();

                var t4 = DirtyTrackerNode.GetOrCreate(x, y, settings, true);

                Assert.AreNotSame(t1, t4);
            }
            private void AddToSyncQueue(DirtyTrackerNode newNode)
            {
                var queue = this.borrowedQueue.Value;
                queue.Enqueue(newNode);
                if (this.processingNode != null)
                {
                    return;
                }

                if (this.processingNode != null)
                {
                    return;
                }

                while (queue.TryDequeue(out this.processingNode))
                {
                    if (this.processingNode.IsDirty)
                    {
                        Copy.PropertyValues(this.processingNode.X, this.processingNode.Y, this.Settings);
                    }
                }

                this.processingNode = null;
            }