Exemplo n.º 1
0
 private void BuildChildren(PropertyAccessTreeNode root)
 {
     for (int i = 0; i < root.Children.Count; i++)
     {
         var childSubscriptionNode = new SubscriptionNode(_subscriberCallback, (PropertyAccessNode)root.Children[i]);
         _children.Add(childSubscriptionNode);
     }
 }
Exemplo n.º 2
0
        public override bool IsRedundantVersion(PropertyAccessTreeNode other)
        {
            var otherAsPropertyNode = other as PropertyAccessNode;
            if (otherAsPropertyNode == null)
                return false;

            return other != this && otherAsPropertyNode.Property == this.Property;
        }
Exemplo n.º 3
0
        public override bool IsRedundantVersion(PropertyAccessTreeNode other)
        {
            ConstantNode otherAsConstantNode = other as ConstantNode;
            if (otherAsConstantNode == null)
                return false;

            return other != this && otherAsConstantNode.Value == this.Value;
        }
Exemplo n.º 4
0
                public RootSubscription(
                    Action <TListener, object> subscriberCallback,
                    PropertyAccessTreeNode parameterNode)
                {
                    _propertyAccessTreeNode = parameterNode;
                    _children           = new List <SubscriptionNode>();
                    _subscriberCallback = subscriberCallback;

                    BuildChildren(parameterNode);
                }
Exemplo n.º 5
0
        public override bool IsRedundantVersion(PropertyAccessTreeNode other)
        {
            var otherAsPropertyNode = other as PropertyAccessNode;

            if (otherAsPropertyNode == null)
            {
                return(false);
            }

            return(other != this && otherAsPropertyNode.Property == this.Property);
        }
Exemplo n.º 6
0
        public override bool IsRedundantVersion(PropertyAccessTreeNode other)
        {
            ConstantNode otherAsConstantNode = other as ConstantNode;

            if (otherAsConstantNode == null)
            {
                return(false);
            }

            return(other != this && otherAsConstantNode.Value == this.Value);
        }
                public RootSubscription(
                    Action <TListener, object, PropertyChangingEventArgs> subscriberChangingCallback,
                    Action <TListener, object, PropertyChangedEventArgs> subscriberChangedCallback,
                    PropertyAccessTreeNode parameterNode)
                {
                    _propertyAccessTreeNode = parameterNode;
                    _children = new List <SubscriptionNode>();
                    _subscriberChangingCallback = subscriberChangingCallback;
                    _subscriberChangedCallback  = subscriberChangedCallback;

                    BuildChildren(parameterNode);
                }
Exemplo n.º 8
0
        public SubscriptionTree CreateSubscriptionTree(INotifyPropertyChanged parameter)
        {
            List <SubscriptionNode> subscribers = new List <SubscriptionNode>(this.Children.Count);

            for (int i = 0; i < this.Children.Count; i++)
            {
                PropertyAccessTreeNode child = this.Children[i];
                if (child.Children.Count > 0)
                {
                    var subscriptionNode = child.CreateSubscription(parameter);
                    subscribers.Add(subscriptionNode);
                }
            }
            var subscriptionTree = new SubscriptionTree(parameter, subscribers);

            return(subscriptionTree);
        }
Exemplo n.º 9
0
        private static void AddBranch(PropertyAccessTree tree, Stack <PropertyAccessTreeNode> currentNodeBranch)
        {
            if (currentNodeBranch.Count == 0)
            {
                return;
            }

            PropertyAccessTreeNode currentNode = currentNodeBranch.Pop();

            tree.Children.Add(currentNode);

            while (currentNodeBranch.Count != 0)
            {
                PropertyAccessTreeNode nextNode = currentNodeBranch.Pop();
                currentNode.Children.Add(nextNode);
                currentNode = nextNode;
            }
        }
        protected void SubscribeToChildren(SubscriptionNode subscriptionNode, INotifyPropertyChanged parameter)
        {
            for (int i = 0; i < this.Children.Count; i++)
            {
                PropertyAccessTreeNode child = this.Children[i];
                if (child.Children.Count == 0)
                {
                    continue;
                }

                SubscriptionNode childSubscriptionNode = child.CreateSubscription(parameter);

                if (subscriptionNode.Children == null)
                {
                    subscriptionNode.Children = new List <SubscriptionNode>();
                }

                subscriptionNode.Children.Add(childSubscriptionNode);
            }
        }
Exemplo n.º 11
0
        private void GetParameterPropertyAccessString(StringBuilder stringBuilder, PropertyAccessTreeNode currentNode)
        {
            foreach (PropertyAccessTreeNode child in currentNode.Children)
            {
                var childAsPropertyAccessNode = child as PropertyAccessNode;

                if (childAsPropertyAccessNode == null)
                {
                    continue;
                }

                if (child.Children.Count > 1)
                {
                    throw new Exception("This property access tree has multiple branches.  Use GetParameterPropertyAccessString only with single branch lambdas like (foo=> foo.Bar) NOT (foo => foo.Bar || foo.Ninja");
                }

                stringBuilder.AppendFormat(
                    stringBuilder.Length == 0 ? "{0}" : ".{0}",
                    childAsPropertyAccessNode.Property.Name);

                GetParameterPropertyAccessString(stringBuilder, childAsPropertyAccessNode);
            }
        }
 public abstract bool IsRedundantVersion(PropertyAccessTreeNode other);
Exemplo n.º 13
0
 public override bool IsRedundantVersion(PropertyAccessTreeNode other)
 {
     var otherAsParameterNode = other as ParameterNode;
     return otherAsParameterNode != null && otherAsParameterNode != this && this.Name == otherAsParameterNode.Name;
 }
Exemplo n.º 14
0
        public override bool IsRedundantVersion(PropertyAccessTreeNode other)
        {
            var otherAsParameterNode = other as ParameterNode;

            return(otherAsParameterNode != null && otherAsParameterNode != this && this.Name == otherAsParameterNode.Name);
        }
 public abstract bool IsRedundantVersion(PropertyAccessTreeNode other);