protected internal override void VisitBindingNode(SnapshotBuilder builder, BindingNode node) { if (builder.IsVisited(node)) { return; } builder.AddNode(node, NodeInfo.Create); base.VisitBindingNode(builder, node); }
protected internal override void VisitBindingNode(SchemaBuilder builder, BindingNode node) { if (builder.IsVisited(node)) { return; } builder.AddNode(node, ReteNode.Create); base.VisitBindingNode(builder, node); }
internal static ReteNode Create(BindingNode node) { var expressions = new[] { new KeyValuePair <string, LambdaExpression>("Expression", node.ExpressionElement.Expression) }; return(new ReteNode(node.Id, NodeType.Binding, outputType: node.ResultType, expressions: expressions, rules: node.NodeInfo.Rules)); }
public bool Binding(BindingNode bindingNode, Parameters parameters, Context context) { var result = this.VisitDefiniteBinding(bindingNode, parameters, context); if (result) { context.BindingContainerSourceCodeBuilder.Append(result.Value.BindingPathSourceCodeBuilder); return(true); } return(false); }
public bool Binding(BindingNode bindingNode, Parameters parameters, Context context) { var result = this.VisitDefiniteBinding(bindingNode); if (result) { context.XamlModificationTracker.Add(bindingNode.TargetElement, new BindingXamlModification(bindingNode.Id, bindingNode.BindingAssignment, context.XamlElementNameProvider)); return(true); } return(false); }
public void RemoveBoundEntity(IEntity entity, IEntityList entityList) { BindingNode node = GetNode(entity, entityList); if (node != null) { node.RemoveNode(); looseNodes.Remove(node); } else { entityList.RemoveEntity(entity); } }
public void AddChild(BindingNode node) { if (FirstChild == null) { FirstChild = node; } else { var t = FirstChild.NextSibling; FirstChild.NextSibling = node; node.PrevSibling = FirstChild; node.NextSibling = t; } node.Parent = this; //var c = FirstChild; }
public void CreateBinding(IEntity entity1, IEntity entity2, IEntityList list1, IEntityList list2) { BindingNode firstNode = GetNode(entity1, list1); if (firstNode == null) { firstNode = new BindingNode(entity1, list1); looseNodes.Add(firstNode); } BindingNode secondNode = GetNode(entity2, list2); if (secondNode == null) { secondNode = new BindingNode(entity2, list2); looseNodes.Add(secondNode); } firstNode.Bind(secondNode); }
private void OnTargetPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(IHasDataContext.DataContext) || e.PropertyName == nameof(IHasDataContext.ParentContainer)) { Refresh(); return; } if (_mode == BindingMode.OneWayToSource || _mode == BindingMode.TwoWay) { var last = _nodes.LastOrDefault(); if (last == null) { return; } lock (_lock) { try { _changingNode = last; if (last.Indices == null) { last.Property.SetValue(last.Object, _property.GetValue(_control)); } else { last.Property.SetValue(last.Object, _property.GetValue(_control), last.Indices); } } catch { if (_strict) { throw; } } finally { _changingNode = null; } } } }
private IEnumerable <Snippet> BuildSnippetsForNode(Binding binding, BindingNode node, ElementNode element) { if (node is BindingLiteral) { return(BuildSnippets(node as BindingLiteral)); } if (node is BindingNameReference) { return(BuildSnippets(node as BindingNameReference, element)); } if (node is BindingPrefixReference) { return(BuildSnippets(binding, node as BindingPrefixReference, element)); } if (!(node is BindingChildReference)) { throw new CompilerException("Binding node type " + node.GetType() + " not understood"); } return(this.BuildSnippets(node as BindingChildReference)); }
private string CreateBinding(BindingNode binding) { var sb = new StringBuilder(); sb.Append("new Binding()").Append(nl) .Append('{').Append(nl); if (!string.IsNullOrWhiteSpace(binding.ElementName)) { sb.Append("ElementName = ").Append(binding.ElementName).Append(',').Append(nl); } sb.Append("Path = ").Append(binding.Path); if (binding.Mode != BindingMode.Default) { sb.Append(',').Append(nl) .Append("Mode = ").Append(binding.Mode); } sb.Append(nl).Append('}'); return(sb.ToString()); }
public void Remove() { if (Parent != null) { if (Parent.FirstChild == this) { Parent.FirstChild = this.NextSibling; } if (PrevSibling != null) { PrevSibling.NextSibling = NextSibling; } if (NextSibling != null) { NextSibling.PrevSibling = PrevSibling; } NextSibling = PrevSibling = null; Parent = null; } }
public void CreateMultipleBindingsOneWay(IEntity entity1, IEntityList sourceList, IEntityList list1, IEntityList list2) { BindingNode firstNode = GetNode(entity1, list1); if (firstNode == null) { firstNode = new BindingNode(entity1, list1); looseNodes.Add(firstNode); } foreach (IEntity entity2 in sourceList) { if (entity2 != null && list2.Contains(entity2)) { BindingNode secondNode = GetNode(entity2, list2); if (secondNode == null) { secondNode = new BindingNode(entity2, list2); looseNodes.Add(secondNode); } firstNode.BindOneWay(secondNode); } } }
internal static NodeInfo Create(BindingNode node) { var expressions = new[] { node.BindingExpression.ToString() }; return(new NodeInfo(NodeType.Binding, string.Empty, Empty, expressions, Empty)); }
private static IEnumerable<Snippet> BuildSnippetsForNode(Binding binding, BindingNode node, ElementNode element) { if (node is BindingLiteral) return BuildSnippets(node as BindingLiteral); if (node is BindingNameReference) return BuildSnippets(node as BindingNameReference, element); if (node is BindingPrefixReference) return BuildSnippets(binding, node as BindingPrefixReference, element); throw new CompilerException("Binding node type " + node.GetType() + " not understood"); }
private static bool TestBetterMatch(string attributeName, string matchingPrefix, BindingNode compareNode) { if (compareNode is BindingNameReference) { var nameReference = (BindingNameReference)compareNode; if (attributeName == nameReference.Name) { // an exact name reference will prevent any wildcard consumption return true; } } if (compareNode is BindingPrefixReference) { var currentPrefix = matchingPrefix ?? ""; var comparePrefix = ((BindingPrefixReference)compareNode).Prefix ?? ""; if (comparePrefix.Length > currentPrefix.Length && attributeName.StartsWith(comparePrefix)) { // A longer wildcard reference which matches the current name will // prevent the shorter from using it return true; } } // otherwise this match is good to go. return false; }
private static bool TestBetterMatch(string attributeName, string matchingPrefix, BindingNode compareNode) { if (compareNode is BindingNameReference) { var nameReference = (BindingNameReference)compareNode; if (attributeName == nameReference.Name) { // an exact name reference will prevent any wildcard consumption return(true); } } if (compareNode is BindingPrefixReference) { var currentPrefix = matchingPrefix ?? ""; var comparePrefix = ((BindingPrefixReference)compareNode).Prefix ?? ""; if (comparePrefix.Length > currentPrefix.Length && attributeName.StartsWith(comparePrefix)) { // A longer wildcard reference which matches the current name will // prevent the shorter from using it return(true); } } // otherwise this match is good to go. return(false); }
protected internal virtual void VisitBindingNode(TContext context, BindingNode node) { VisitBetaNode(context, node); }
private static bool TestBetterMatch(string attributeName, string matchingPrefix, BindingNode compareNode) { if (compareNode is BindingNameReference) { BindingNameReference reference = (BindingNameReference)compareNode; if (attributeName == reference.Name) { return(true); } } if (compareNode is BindingPrefixReference) { string str = matchingPrefix ?? ""; string str2 = ((BindingPrefixReference)compareNode).Prefix ?? ""; if ((str2.Length > str.Length) && attributeName.StartsWith(str2)) { return(true); } } return(false); }
public void AddChild(BindingNode node) { node._parent = this; _children.Add(node); }
public void Binding(BindingNode bindingNode, StringBuilder stringBuilder, int indent) { stringBuilder.AppendLine($"{' '.Repeat(indent * 2)}{bindingNode}"); }