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); } }
public override bool IsRedundantVersion(PropertyAccessTreeNode other) { var otherAsPropertyNode = other as PropertyAccessNode; if (otherAsPropertyNode == null) return false; return other != this && otherAsPropertyNode.Property == this.Property; }
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> subscriberCallback, PropertyAccessTreeNode parameterNode) { _propertyAccessTreeNode = parameterNode; _children = new List <SubscriptionNode>(); _subscriberCallback = subscriberCallback; BuildChildren(parameterNode); }
public override bool IsRedundantVersion(PropertyAccessTreeNode other) { var otherAsPropertyNode = other as PropertyAccessNode; if (otherAsPropertyNode == null) { return(false); } return(other != this && otherAsPropertyNode.Property == this.Property); }
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); }
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); }
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); } }
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);
public override bool IsRedundantVersion(PropertyAccessTreeNode other) { var otherAsParameterNode = other as ParameterNode; return otherAsParameterNode != null && otherAsParameterNode != this && this.Name == otherAsParameterNode.Name; }
public override bool IsRedundantVersion(PropertyAccessTreeNode other) { var otherAsParameterNode = other as ParameterNode; return(otherAsParameterNode != null && otherAsParameterNode != this && this.Name == otherAsParameterNode.Name); }