Exemplo n.º 1
0
        public void VisitNode(INodeVisitor visitor, IList <Node> body, IList <Chunk> chunks)
        {
            Transform(Node, body);

            visitor.Accept(Node);
            visitor.Accept(body);
            if (!Node.IsEmptyElement)
            {
                visitor.Accept(new EndElementNode(Node.Name));
            }
        }
        public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
        {
            Transform(Node, body);

            visitor.Accept(Node);
            visitor.Accept(body);
            if (!Node.IsEmptyElement)
            {
                visitor.Accept(new EndElementNode(Node.Name));
            }
        }
Exemplo n.º 3
0
        public void VisitNode(INodeVisitor visitor, IList <Node> body, IList <Chunk> chunks)
        {
            var registerTarget = string.Format(
                @"RegisterTarget(""{0}"", ""{1}"", ""{2}"", __target_{3});",
                _idAttribute.Value,
                _classAttribute != null ? _classAttribute.Value : "",
                _descriptionAttribute != null ? _descriptionAttribute.Value : "",
                _targetExtensionCount);

            if (_targetAttribute != null)
            {
                registerTarget +=
                    Environment.NewLine +
                    string.Format(
                        @"RegisterTarget(""{0}"", ""{1}"", null, null);",
                        _targetAttribute.Value,
                        _idAttribute.Value);
            }

            var beginLambda = string.Format(
                @"__target_{0} = () => {{",
                _targetExtensionCount);
            const string endLambda = "};";

            var startingTarget = string.Format(
                @"StartingTarget(""{0}"");",
                _idAttribute.Value);

            var nameAttribute = new AttributeNode("name", _idAttribute.QuotChar, _idAttribute.Nodes)
            {
                OriginalNode = _idAttribute
            };

            var macroAttributes = _targetElement.Attributes
                                  .Where(x => x != _idAttribute && x != _classAttribute && x != _descriptionAttribute)
                                  .Concat(new[] { nameAttribute })
                                  .ToList();
            var macroElement = new SpecialNode(new ElementNode("macro", macroAttributes, false));

            var onceAttribute = new AttributeNode("once", _idAttribute.QuotChar, _idAttribute.Nodes);
            var testElement   = new SpecialNode(new ElementNode("test", new[] { onceAttribute }, false));


            macroElement.Body.Add(testElement);
            testElement.Body = body;
            testElement.Body.Insert(0, new StatementNode(startingTarget));

            visitor.Accept(new StatementNode(beginLambda));
            visitor.Accept(testElement);
            visitor.Accept(new StatementNode(endLambda));
            visitor.Accept(new StatementNode(registerTarget));
        }
Exemplo n.º 4
0
        public void LayerTraverse(INodeVisitor <T> visitor)
        {
            if (m_root == null)
            {
                return;
            }
            Queue <BinaryTreeNode <T> > sequence = new Queue <BinaryTreeNode <T> >();

            sequence.Enqueue(m_root);
            BinaryTreeNode <T> current = null;

            while (sequence.Count > 0)
            {
                current = sequence.Dequeue();
                visitor.Accept(current.Value);
                if (current.Left != null)
                {
                    sequence.Enqueue(current.Left);
                }
                if (current.Right != null)
                {
                    sequence.Enqueue(current.Right);
                }
            }
        }
Exemplo n.º 5
0
        public void PostorderTraverse(INodeVisitor <T> visitor)
        {
            if (m_root == null)
            {
                return;
            }
            Stack <BinaryTreeNode <T> >   sequence = new Stack <BinaryTreeNode <T> >();
            HashSet <BinaryTreeNode <T> > record   = new HashSet <BinaryTreeNode <T> >();
            BinaryTreeNode <T>            current  = null;

            sequence.Push(m_root);
            while (sequence.Count > 0)
            {
                current = sequence.Peek();
                bool left_child_visited = current.Left != null?record.Contains(current.Left) : true;

                bool right_child_visited = current.Right != null?record.Contains(current.Right) : true;

                if (left_child_visited && right_child_visited)
                {
                    sequence.Pop();
                    visitor.Accept(current.Value);
                    record.Add(current);
                }
                if (!right_child_visited)
                {
                    sequence.Push(current.Right);
                }
                if (!left_child_visited)
                {
                    sequence.Push(current.Left);
                }
            }
        }
        public void VisitNode(INodeVisitor visitor, IList <Node> body, IList <Chunk> chunks)
        {
            SparkElementWrapper sparkElementWrapper = new SparkElementWrapper(_element, body);

            _sparkElementTransformer.Transform(sparkElementWrapper);
            visitor.Accept(_element);
            if (sparkElementWrapper.Body.Count > 0)
            {
                _element.IsEmptyElement = false;
                visitor.Accept(sparkElementWrapper.Body);
                visitor.Accept(new EndElementNode(_element.Name));
            }
            else
            {
                _element.IsEmptyElement = true;
            }
        }
        public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
        {
            visitor.Accept(body);

            var sectionVisitor = new ViewComponentSectionChunkBuilderVisitor();
            sectionVisitor.Accept(body);
            sections = sectionVisitor.Sections;
            attributes = sectionVisitor.Attributes;
        }
Exemplo n.º 8
0
        public void VisitNode(INodeVisitor visitor, IList <Node> body, IList <Chunk> chunks)
        {
            visitor.Accept(body);

            var sectionVisitor = new ViewComponentSectionChunkBuilderVisitor();

            sectionVisitor.Accept(body);
            sections   = sectionVisitor.Sections;
            attributes = sectionVisitor.Attributes;
        }
Exemplo n.º 9
0
 private void PostorderTraverse(INodeVisitor <T> visitor, BinaryTreeNode <T> node)
 {
     if (node == null)
     {
         return;
     }
     PostorderTraverse(visitor, node.Left);
     PostorderTraverse(visitor, node.Right);
     visitor.Accept(node.Value);
 }
Exemplo n.º 10
0
 public void VisitNode(INodeVisitor visitor, IList <Node> body, IList <Chunk> chunks)
 {
     if (visitor is ChunkBuilderVisitor)
     {
         var sectionVisitor = new ViewComponentVisitor((ChunkBuilderVisitor)visitor, info);
         sectionVisitor.Accept(body);
         sectionsChunks     = sectionVisitor.Sections;
         sectionsAttributes = sectionVisitor.Attributes;
     }
     else
     {
         visitor.Accept(body);
     }
 }
Exemplo n.º 11
0
        public void InorderTraverse(INodeVisitor <T> visitor)
        {
            if (m_root == null)
            {
                return;
            }
            Stack <BinaryTreeNode <T> > sequence = new Stack <BinaryTreeNode <T> >();
            BinaryTreeNode <T>          current  = m_root;

            while (current != null || sequence.Count > 0)
            {
                while (current != null)
                {
                    sequence.Push(current);
                    current = current.Left;
                }
                current = sequence.Pop();
                visitor.Accept(current.Value);
                current = current.Right;
            }
        }
Exemplo n.º 12
0
        public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
        {
            if (visitor is ChunkBuilderVisitor)
            {
                var newNodes = new List<Node>();

                Utilities.AddApplyPathModifier(_mNode.Attributes,"href");

                newNodes.Add(_mNode);
                if (!_mNode.IsEmptyElement)
                {
                    newNodes.AddRange(body);
                    newNodes.Add(new EndElementNode(_mNode.Name));
                }

                // visit the new nodes normally
                visitor.Accept(newNodes);

                // keep the output chunks to render later
                _mChunks = chunks;
            }
        }
Exemplo n.º 13
0
        public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
        {
            if (visitor is ChunkBuilderVisitor)
            {
                var newNodes = new List<Node>();

                var classNode = _mNode.Attributes.SingleOrDefault(x => x.Name == "class") ??
                                new AttributeNode("class", "");
                var newclassNode = Utilities.AddMethodCallingToAttributeValue(classNode, Constants.ADDBROWSERDETAILS);
                _mNode.Attributes.Remove(classNode);
                _mNode.Attributes.Add(newclassNode);

                newNodes.Add(_mNode);
                newNodes.AddRange(body);
                newNodes.Add(new EndElementNode(_mNode.Name));

                // visit the new nodes normally
                visitor.Accept(newNodes);

                // keep the output chunks to render later
                _mChunks = chunks;
            }
        }
Exemplo n.º 14
0
        public void PreorderTraverse(INodeVisitor <T> visitor)
        {
            if (m_root == null)
            {
                return;
            }
            Stack <BinaryTreeNode <T> > sequence = new Stack <BinaryTreeNode <T> >();
            BinaryTreeNode <T>          current  = null;

            sequence.Push(m_root);
            while (sequence.Count > 0)
            {
                current = sequence.Pop();
                visitor.Accept(current.Value);
                if (current.Right != null)
                {
                    sequence.Push(current.Right);
                }
                if (current.Left != null)
                {
                    sequence.Push(current.Left);
                }
            }
        }
Exemplo n.º 15
0
        public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
        {
            var registerTarget = string.Format(
                @"RegisterTarget(""{0}"", ""{1}"", ""{2}"", __target_{3});",
                _idAttribute.Value,
                _classAttribute != null ? _classAttribute.Value : "",
                _descriptionAttribute != null ? _descriptionAttribute.Value : "",
                _targetExtensionCount);

            if (_targetAttribute != null)
            {
                registerTarget +=
                    Environment.NewLine +
                    string.Format(
                        @"RegisterTarget(""{0}"", ""{1}"", null, null);",
                        _targetAttribute.Value,
                        _idAttribute.Value);
            }

            var beginLambda = string.Format(
                @"__target_{0} = () => {{",
                _targetExtensionCount);
            const string endLambda = "};";

            var startingTarget = string.Format(
                @"StartingTarget(""{0}"");",
                _idAttribute.Value);

            var nameAttribute = new AttributeNode("name", _idAttribute.QuotChar, _idAttribute.Nodes) { OriginalNode = _idAttribute };

            var macroAttributes = _targetElement.Attributes
                .Where(x => x != _idAttribute && x != _classAttribute && x != _descriptionAttribute)
                .Concat(new[] { nameAttribute })
                .ToList();
            var macroElement = new SpecialNode(new ElementNode("macro", macroAttributes, false));

            var onceAttribute = new AttributeNode("once", _idAttribute.QuotChar, _idAttribute.Nodes);
            var testElement = new SpecialNode(new ElementNode("test", new[] { onceAttribute }, false));

            macroElement.Body.Add(testElement);
            testElement.Body = body;
            testElement.Body.Insert(0, new StatementNode(startingTarget));

            visitor.Accept(new StatementNode(beginLambda));
            visitor.Accept(testElement);
            visitor.Accept(new StatementNode(endLambda));
            visitor.Accept(new StatementNode(registerTarget));
        }
Exemplo n.º 16
0
        public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
        {
            if (visitor is ChunkBuilderVisitor)
            {
                var newNodes = new List<Node>();

                Utilities.AddApplyPathModifier(_mNode.Attributes, "action");
                HttpMethodOverride(body);

                if (validate)
                {

                    var idNode = _mNode.Attributes.SingleOrDefault(x => x.Name == "id");

                    var id = (idNode != null) ? idNode.Value : GenerateFormId();

                    _mNode.Attributes.Remove(_mNode.Attributes.FirstOrDefault(x => x.Name == Constants.VALIDATE_ATTRIBUTE));
                    newNodes.Add(_mNode);

                    var code = String.Format(Constants.HTML_GETCLIENTVALIDATIONJSON, id, outputStyle, modelName);

                    //For MVC we have to create MvcForm first
                    if (outputStyle.Equals(OutputStyle.MVC))
                    {
                        var codeForMvc = String.Format(Constants.CREATEMVCFORM, id);
                        newNodes.Add(new StatementNode(codeForMvc));
                    }
                    newNodes.AddRange(body);
                    newNodes.Add(new StatementNode(code));
                }
                else
                {
                    newNodes.Add(_mNode);
                    newNodes.AddRange(body);
                }

                newNodes.Add(new EndElementNode(_mNode.Name));

                // visit the new nodes normally
                visitor.Accept(newNodes);

                // keep the output chunks to render later
                _mChunks = chunks;
            }
        }
Exemplo n.º 17
0
 public void VisitNode(INodeVisitor visitor, IList <Node> body, IList <Chunk> chunks)
 {
     visitor.Accept(body);
 }
Exemplo n.º 18
0
 public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
 {
     if (visitor is ChunkBuilderVisitor)
     {
         var sectionVisitor = new ViewComponentVisitor((ChunkBuilderVisitor)visitor, info);
         sectionVisitor.Accept(body);
         sectionsChunks = sectionVisitor.Sections;
         sectionsAttributes = sectionVisitor.Attributes;
     }
     else
     {
         visitor.Accept(body);
     }
 }
Exemplo n.º 19
0
 public override void Accept(INodeVisitor visitor)
 {
     visitor.Accept(this);
 }
Exemplo n.º 20
0
 public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
 {
     visitor.Accept(body);
 }