예제 #1
0
 protected internal override void VisitBindingNode(SnapshotBuilder builder, BindingNode node)
 {
     if (builder.IsVisited(node))
     {
         return;
     }
     builder.AddNode(node, NodeInfo.Create);
     base.VisitBindingNode(builder, node);
 }
예제 #2
0
 protected internal override void VisitBindingNode(SchemaBuilder builder, BindingNode node)
 {
     if (builder.IsVisited(node))
     {
         return;
     }
     builder.AddNode(node, ReteNode.Create);
     base.VisitBindingNode(builder, node);
 }
예제 #3
0
파일: ReteNode.cs 프로젝트: arastoul/NRules
        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));
        }
예제 #4
0
        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);
        }
예제 #6
0
        public void RemoveBoundEntity(IEntity entity, IEntityList entityList)
        {
            BindingNode node = GetNode(entity, entityList);

            if (node != null)
            {
                node.RemoveNode();
                looseNodes.Remove(node);
            }
            else
            {
                entityList.RemoveEntity(entity);
            }
        }
예제 #7
0
    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;
    }
예제 #8
0
        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);
        }
예제 #9
0
 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;
             }
         }
     }
 }
예제 #10
0
 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));
 }
예제 #11
0
파일: CSharpBuilder.cs 프로젝트: sys27/Edge
        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());
        }
예제 #12
0
    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;
        }
    }
예제 #13
0
        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);
                }
            }
        }
예제 #14
0
        internal static NodeInfo Create(BindingNode node)
        {
            var expressions = new[] { node.BindingExpression.ToString() };

            return(new NodeInfo(NodeType.Binding, string.Empty, Empty, expressions, Empty));
        }
예제 #15
0
        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");
        }
예제 #16
0
        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;
        }
예제 #17
0
        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);
        }
예제 #18
0
 protected internal virtual void VisitBindingNode(TContext context, BindingNode node)
 {
     VisitBetaNode(context, node);
 }
예제 #19
0
 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);
 }
예제 #20
0
 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}");
 }