Beispiel #1
0
        private bool TryCreateChildNode(int index, out IUnsubscriber <IChildNode <ChangeTrackerNode> > result)
        {
            var value = this.SourceList.ElementAtOrMissing(index);

            if (value == PaddedPairs.MissingItem)
            {
                result = null;
                return(false);
            }

            IRefCounted <ChangeTrackerNode> node;

            if (TryGetOrCreate(value, this.Settings, false, out node))
            {
                using (node)
                {
                    var indexNode = ChildNodes <ChangeTrackerNode> .CreateChildNode(this, node.Value, index);

                    indexNode.Changed += this.OnChildNodeChanged;
                    result             = indexNode.UnsubscribeAndDispose(n => n.Changed -= this.OnChildNodeChanged);
                    return(true);
                }
            }

            result = null;
            return(false);
        }
        private IUnsubscriber <IChildNode <DirtyTrackerNode> > CreateChildNode(int index)
        {
            if (!this.IsTrackingCollectionItems)
            {
                return(null);
            }

            var xValue = this.XList.ElementAtOrMissing(index);
            var yValue = this.YList.ElementAtOrMissing(index);

            IRefCounted <DirtyTrackerNode> node;

            if (this.TrCreateChild(xValue, yValue, out node))
            {
                using (node)
                {
                    var childNode = ChildNodes <DirtyTrackerNode> .CreateChildNode(this, node.Value, index);

                    childNode.Changed += this.OnChildNodeChanged;
                    return(childNode.UnsubscribeAndDispose(x => x.Changed -= this.OnChildNodeChanged));
                }
            }

            return(null);
        }
Beispiel #3
0
        private void UpdatePropertyNode(PropertyInfo property)
        {
            if (this.Settings.IsIgnoringProperty(property) ||
                !Is.Trackable(property.PropertyType))
            {
                return;
            }

            var getter = this.Settings.GetOrCreateGetterAndSetter(property);
            var value  = getter.GetValue(this.Source);
            IRefCounted <ChangeTrackerNode> node;

            if (TryGetOrCreate(value, this.Settings, false, out node))
            {
                using (node)
                {
                    var propertyNode = ChildNodes <ChangeTrackerNode> .CreateChildNode(this, node.Value, property);

                    propertyNode.Changed += this.OnChildNodeChanged;
                    IUnsubscriber <IChildNode <ChangeTrackerNode> > childNode = propertyNode.UnsubscribeAndDispose(n => n.Changed -= this.OnChildNodeChanged);
                    this.Children.SetValue(property, childNode);
                }
            }
            else
            {
                this.Children.Remove(property);
            }
        }
        private void UpdatePropertyChildNode(PropertyInfo propertyInfo)
        {
            if (this.Settings.IsIgnoringProperty(propertyInfo))
            {
                return;
            }

            if (this.TrackProperties.Contains(propertyInfo) &&
                (this.Settings.ReferenceHandling == ReferenceHandling.Structural))
            {
                var getter = this.Settings.GetOrCreateGetterAndSetter(propertyInfo);
                var xValue = getter.GetValue(this.X);
                var yValue = getter.GetValue(this.Y);
                IRefCounted <DirtyTrackerNode> node;
                if (this.TrCreateChild(xValue, yValue, out node))
                {
                    using (node)
                    {
                        var childNode = ChildNodes <DirtyTrackerNode> .CreateChildNode(this, node.Value, propertyInfo);

                        childNode.Changed += this.OnChildNodeChanged;
                        this.Children.SetValue(propertyInfo, childNode.UnsubscribeAndDispose(x => x.Changed -= this.OnChildNodeChanged));
                    }
                }
                else
                {
                    this.Children.Remove(propertyInfo);
                }
            }
        }