예제 #1
0
 protected virtual void AddChild(XElement data, string combinedId)
 {
     foreach (var org in Data.Elements("market"))
     {
         ChildNodes.Add(new MarketNode(org, combinedId, Level + 1));
     }
 }
예제 #2
0
        internal BuildTimeScopeBlock AddChild()
        {
            BuildTimeScopeBlock block = new BuildTimeScopeBlock(this);

            ChildNodes.Add(block);
            return(block);
        }
예제 #3
0
 protected override void AddChild(XElement data, string combinedId)
 {
     foreach (var item in Data.Elements("country"))
     {
         ChildNodes.Add(new CountryNode(item, combinedId, Level + 1));
     }
 }
예제 #4
0
        protected override void WriteInner(XmlWriter writer)
        {
            var nodeName = Data.Attribute("name").Value;

            nodeName = ClearNonIdText(nodeName);
            var nodeId     = nodeName;
            var combinedId = ParentId + "_" + nodeName;


            ChildNodes.Add(new DivAdminTreeNode(combinedId, ParentId));

            var input = new InputNode(nodeName, nodeId, ParentId);

            ChildNodes.Add(input);

            AddChild(Data, combinedId);


            if (Data.Elements("users").Count() > 0)
            {
                foreach (var org in Data.Element("users").Elements("user"))
                {
                    ChildNodes.Add(new UserNode(org, combinedId));
                }
            }
            base.WriteInner(writer);
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method sets up the AST node and its children in the AST.</summary>
 ///
 /// <param name="context">The parsing context.</param>
 /// <param name="treeNode">The corresponding node in the parse tree.</param>
 ///--------------------------------------------------------------------------------
 public override void Init(ParsingContext context, ParseTreeNode treeNode)
 {
     try
     {
         base.Init(context, treeNode);
         foreach (ParseTreeNode node in treeNode.ChildNodes)
         {
             if (node.AstNode is ParameterNode)
             {
                 Parameter = node.AstNode as ParameterNode;
                 ChildNodes.Add(node.AstNode as ParameterNode);
             }
             else
             {
                 VariableName = node.FindTokenAndGetText();
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         ThrowASTException(ex, true);
     }
 }
        public void Initialize(WordNode parentNode, string characters)
        {
            if (string.IsNullOrEmpty(characters))
            {
                return;
            }
            var firstChar = characters[0];

            var node = ChildNodes.Find(r => r.Character == firstChar);

            if (node == null)
            {
                var newChild = new WordNode(characters.Remove(0, 1))
                {
                    Character = firstChar
                };
                newChild.Parent = parentNode;
                if (characters.Length == 1)
                {
                    newChild.IsWord = true;
                }

                ChildNodes.Add(newChild);
            }
            else
            {
                node.Initialize(node, characters.Remove(0, 1));
            }
        }
예제 #7
0
        public TreeNode AddChild(string text, string value)
        {
            var child = new TreeNode(text, value);

            ChildNodes.Add(child);
            return(child);
        }
예제 #8
0
 private void AddChild(NodeControl node)
 {
     if (!ChildNodes.Contains(node))
     {
         ChildNodes.Add(node);
     }
 }
        protected override void WriteInner(System.Xml.XmlWriter writer)
        {
            var anchorContainer = new ComplexNode();

            anchorContainer.Classes.Add("anchor");

            var anchor = new ComplexNode("a");

            anchor.Attributes.Add("href", "FileDownload/DownloadFile?fileName=" + _downloadFilePath);

            var img = new SimpleNode("img", string.Empty);

            img.Attributes.Add("src", _imagePath);

            anchor.ChildNodes.Add(img);

            var span = new SimpleNode("span", _downloadText);

            anchor.ChildNodes.Add(span);


            anchorContainer.ChildNodes.Add(anchor);
            ChildNodes.Add(anchorContainer);

            base.WriteInner(writer);
        }
예제 #10
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method sets up the AST node and its children in the AST.</summary>
 ///
 /// <param name="context">The parsing context.</param>
 /// <param name="treeNode">The corresponding node in the parse tree.</param>
 ///--------------------------------------------------------------------------------
 public override void Init(ParsingContext context, ParseTreeNode treeNode)
 {
     try
     {
         base.Init(context, treeNode);
         Statements = new List <IStatementNode>();
         foreach (ParseTreeNode node in treeNode.ChildNodes)
         {
             if (node.AstNode is ParameterNode)
             {
                 DirectoryPath = node.AstNode as ParameterNode;
                 ChildNodes.Add(node.AstNode as ParameterNode);
             }
             else if (node.AstNode is LiteralValueNode)
             {
                 Extensions = node.FindToken().ValueString;
             }
             else if (node.AstNode is StatementListNode)
             {
                 (node.AstNode as StatementListNode).GetStatements(node, Statements, ChildNodes);
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         ThrowASTException(ex, true);
     }
 }
예제 #11
0
파일: TNode.cs 프로젝트: modulexcite/nunit
        /// <summary>
        /// Adds a new element with a value as a child of the current node and returns it.
        /// </summary>
        /// <param name="name">The element name</param>
        /// <param name="value">The text content of the new element</param>
        /// <returns>The newly created child element</returns>
        public TNode AddElement(string name, string value)
        {
            TNode childResult = new TNode(name, value);

            ChildNodes.Add(childResult);
            return(childResult);
        }
예제 #12
0
 public ExpandCollapseHyperLinkTableCell(string name = "td")
     : base(name)
 {
     //Classes.Add("ExpandCollapseHyperLinkText");
     ChildNodes.Add(ImgInnerNode);
     ChildNodes.Add(HyperLinkInnerNode);
 }
예제 #13
0
        internal void AddNode(IList <string> routeTemplateFragments, Type requestHandler)
        {
            var headFragment = routeTemplateFragments.First();
            var remainingTemplateFragments = routeTemplateFragments.Skip(1).ToList();

            var childNode = FindChildNode(headFragment);

            if (childNode != null)
            {
                if (remainingTemplateFragments.Any())
                {
                    childNode.AddNode(remainingTemplateFragments, requestHandler);
                }
                else
                {
                    childNode.RequestHandler = requestHandler;
                }
            }
            else
            {
                var newChildNode = new RouteHandlerLookupNode(headFragment, remainingTemplateFragments, requestHandler);
                ChildNodes.Add(newChildNode);
                if (remainingTemplateFragments.Any())
                {
                    newChildNode.AddNode(remainingTemplateFragments, requestHandler);
                }
            }
        }
예제 #14
0
        internal override void ReadChildElement(MSBuildXmlReader reader)
        {
            MSBuildObject ob = null;

            switch (reader.LocalName)
            {
            case "ItemGroup": ob = new MSBuildItemGroup(); break;

            case "PropertyGroup": ob = new MSBuildPropertyGroup(); break;

            case "ImportGroup": ob = new MSBuildImportGroup(); break;

            case "Import": ob = new MSBuildImport(); break;

            case "Target": ob = new MSBuildTarget(); break;

            case "Choose": ob = new MSBuildChoose(); break;

            case "ProjectExtensions": ob = new MSBuildProjectExtensions(); break;

            default: ob = new MSBuildXmlElement(); break;
            }
            if (ob != null)
            {
                ob.ParentNode = this;
                ob.Read(reader);
                ChildNodes = ChildNodes.Add(ob);
            }
            else
            {
                base.ReadChildElement(reader);
            }
        }
예제 #15
0
        /// <summary>
        /// Adds a new element as a child of the current node and returns it.
        /// </summary>
        /// <param name="name">The element name.</param>
        /// <returns>The newly created child element</returns>
        public XmlNode AddElement(string name)
        {
            XmlNode childResult = new XmlNode(name);

            ChildNodes.Add(childResult);
            return(childResult);
        }
예제 #16
0
        /// <summary>
        /// Adds a new element with a value as a child of the current node and returns it.
        /// The value will be output using a CDATA section.
        /// </summary>
        /// <param name="name">The element name</param>
        /// <param name="value">The text content of the new element</param>
        /// <returns>The newly created child element</returns>
        public TNode AddElementWithCDATA(string name, string value)
        {
            TNode childResult = new TNode(name, EscapeInvalidXmlCharacters(value), true);

            ChildNodes.Add(childResult);
            return(childResult);
        }
예제 #17
0
        public MSBuildItemGroup AddNewItemGroup()
        {
            AssertCanModify();
            var group = new MSBuildItemGroup();

            MSBuildObject refNode   = null;
            var           lastGroup = ItemGroups.LastOrDefault();

            if (lastGroup != null)
            {
                refNode = lastGroup;
            }
            else
            {
                var g = PropertyGroups.LastOrDefault();
                if (g != null)
                {
                    refNode = g;
                }
            }

            group.ParentNode = this;
            if (refNode != null)
            {
                ChildNodes = ChildNodes.Insert(ChildNodes.IndexOf(refNode) + 1, group);
            }
            else
            {
                ChildNodes = ChildNodes.Add(group);
            }

            group.ResetIndent(true);
            NotifyChanged();
            return(group);
        }
예제 #18
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method sets up the AST node and its children in the AST.</summary>
 ///
 /// <param name="context">The parsing context.</param>
 /// <param name="treeNode">The corresponding node in the parse tree.</param>
 ///--------------------------------------------------------------------------------
 public override void Init(ParsingContext context, ParseTreeNode treeNode)
 {
     try
     {
         base.Init(context, treeNode);
         foreach (ParseTreeNode node in treeNode.ChildNodes)
         {
             if (node.AstNode is ModelContextNode)
             {
                 ModelContext = node.AstNode as ModelContextNode;
                 ChildNodes.Add(node.AstNode as ModelContextNode);
             }
             else if (node.AstNode is InClauseNode)
             {
                 if (node.ChildNodes.Count > 0)
                 {
                     InClause = node.AstNode as InClauseNode;
                     ChildNodes.Add(node.AstNode as InClauseNode);
                 }
             }
             else if (node.AstNode is WhereClauseNode)
             {
                 if (node.ChildNodes.Count > 0)
                 {
                     WhereClause = node.AstNode as WhereClauseNode;
                     ChildNodes.Add(node.AstNode as WhereClauseNode);
                 }
             }
             else if (node.AstNode is LimitClauseNode)
             {
                 if (node.ChildNodes.Count > 0)
                 {
                     LimitClause = node.AstNode as LimitClauseNode;
                     ChildNodes.Add(node.AstNode as LimitClauseNode);
                 }
             }
             else if (node.AstNode is SortClauseNode)
             {
                 if (node.ChildNodes.Count > 0)
                 {
                     SortClause = node.AstNode as SortClauseNode;
                     ChildNodes.Add(node.AstNode as SortClauseNode);
                 }
             }
             else
             {
                 ForeachHelperName = node.FindTokenAndGetText();
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         ThrowASTException(ex, true);
     }
 }
예제 #19
0
        /// <summary>
        /// Calculate the node
        /// </summary>
        /// <param name="board">Current board state</param>
        /// <param name="currentPosition">Position in board to set</param>
        /// <param name="currentMove">Current move (either Computer or Human)</param>
        /// <param name="depth">Current depth. Used for choosing earliest winning/losing move</param>
        public MiniMaxNode(Board board, int currentPosition, Board.Cell currentMove, int depth)
        {
            // Create the child nodes list
            this.ChildNodes = new List <MiniMaxNode>();

            // Save the index to the cell we are updating. This way we always know what move
            // this node corresponds to
            this.UpdatedCellIndex = currentPosition;
            // Set the cell to Computer/Human
            board.Cells[this.UpdatedCellIndex] = currentMove;

            if (board.GetState() == Board.State.ComputerWins)
            {
                // If Computer wins, give it a high score, but deduct the current depth
                // (So that quick wins have higher scores than lengthy wins)
                this.Score = 10 - depth;
            }
            else if (board.GetState() == Board.State.HumanWins)
            {
                // If Human wins, give it a low score, but add the current depth
                // (So that quick loses have lower scores than lengthy loses)
                this.Score = -10 + depth;
            }
            else if (board.GetState() == Board.State.Draw)
            {
                // If it's a draw, just set to neutral
                this.Score = 0;
            }
            else
            {
                // Invert the player
                var nextMove = currentMove == Board.Cell.Computer ? Board.Cell.Human : Board.Cell.Computer;

                for (var i = 0; i < Board.BoardSize; i++)
                {
                    // For each empty cell
                    if (board.Cells[i] == Board.Cell.Empty)
                    {
                        // Clone the board
                        var childBoard = board.Clone();
                        // Calculate child moves
                        var miniMaxNode = new MiniMaxNode(childBoard, i, nextMove, depth + 1);
                        ChildNodes.Add(miniMaxNode);
                    }
                }

                if (currentMove == Board.Cell.Computer)
                {
                    // Since this isn't a terminal node, give the current node the best score
                    // amongst the child nodes..
                    this.Score = this.ChildNodes.OrderBy(n => n.Score).First().Score;
                }
                else
                {
                    // ..or for Human moves, give it the worst score amongst the children
                    this.Score = this.ChildNodes.OrderBy(n => n.Score).Last().Score;
                }
            }
        }
예제 #20
0
 public void AddChild(TData data)
 {
     if (data != null)
     {
         var node = new TreeNode <TData>(data);
         ChildNodes.Add(node);
     }
 }
예제 #21
0
 protected Element this[INode child]
 {
     get
     {
         ChildNodes.Add(child);
         return(this);
     }
 }
예제 #22
0
 public void AppendChild(IHtmlNode node)
 {
     ChildNodes.Add(node);
     if (node is IHtmlElement element)
     {
         ChildElements.Add(element);
     }
 }
예제 #23
0
        internal override void ReadChildElement(MSBuildXmlReader reader)
        {
            var item = new MSBuildItem();

            item.ParentNode = this;
            item.Read(reader);
            ChildNodes = ChildNodes.Add(item);
        }
예제 #24
0
 public new GenericElement this[INode child]
 {
     get
     {
         ChildNodes.Add(child);
         return(this);
     }
 }
 public void AppendChild(StreamGraphNode node)
 {
     if (!ChildNodes.Contains(node))
     {
         ChildNodes.Add(node);
         node.ParentNodes.Add(this);
     }
 }
예제 #26
0
 public virtual void SetParentInChildNode(IAstNode node)
 {
     if (ChildNodes == null)
     {
         ChildNodes = new List <IAstNode>();
     }
     ChildNodes.Add(node);
 }
예제 #27
0
        public void AddPropertyGroup(MSBuildPropertyGroup group, bool insertAtEnd = true, MSBuildObject beforeObject = null)
        {
            AssertCanModify();
            if (group.ParentProject != null)
            {
                throw new InvalidOperationException("Group already belongs to a project");
            }

            group.ParentNode = this;

            bool added = false;

            if (beforeObject != null)
            {
                var index = ChildNodes.IndexOf(beforeObject);
                if (index != -1)
                {
                    ChildNodes = ChildNodes.Insert(index, group);
                    added      = true;
                }
            }
            if (!added)
            {
                if (insertAtEnd)
                {
                    var last = ChildNodes.FindLastIndex(g => g is MSBuildPropertyGroup);
                    if (last != -1)
                    {
                        ChildNodes = ChildNodes.Insert(last + 1, group);
                        added      = true;
                    }
                }
                else
                {
                    var first = ChildNodes.FindIndex(g => g is MSBuildPropertyGroup);
                    if (first != -1)
                    {
                        ChildNodes = ChildNodes.Insert(first, group);
                        added      = true;
                    }
                }
                if (!added)
                {
                    var first = ChildNodes.FindIndex(g => g is MSBuildItemGroup);
                    if (first != -1)
                    {
                        ChildNodes = ChildNodes.Insert(first, group);
                    }
                    else
                    {
                        ChildNodes = ChildNodes.Add(group);
                    }
                }
            }

            group.ResetIndent(true);
            NotifyChanged();
        }
예제 #28
0
        public void AddRestRequestHandler(RestDigestibleUri uri, RestMethod method, RestRequestHandler handler)
        {
            if (uri.IsLastNode || this is WildCardUriRequestHandlerNode)
            {
                switch (method)
                {
                case RestMethod.GET:
                    if (HttpGetRequestHandler != null)
                    {
                        throw new Exception("Handler already defined");
                    }
                    HttpGetRequestHandler = handler;
                    return;

                case RestMethod.POST:
                    if (HttpPostRequestHandler != null)
                    {
                        throw new Exception("Handler already defined");
                    }
                    HttpPostRequestHandler = handler;
                    return;

                default:
                    throw new Exception("Unknown REST Method.");
                }
            }

            uri.NextNode();

            foreach (var childNode in ChildNodes)
            {
                if (childNode.MatchesUriPattern(uri) && ((childNode is ParameterUriRequestHandlerNode && uri.IsCurrentNodeParameterDefinition) ||
                                                         childNode is NamedUriRequestHandlerNode && !uri.IsCurrentNodeParameterDefinition))
                {
                    childNode.AddRestRequestHandler(uri, method, handler);
                    return;
                }
            }

            UriRequestHandlerNode newChildNode;

            if (uri.IsCurrentNodeParameterDefinition)
            {
                newChildNode = new ParameterUriRequestHandlerNode(uri, method, handler);
            }
            else if (uri.IsWildCardNodeDefinition)
            {
                newChildNode = new WildCardUriRequestHandlerNode(uri, method, handler);
            }
            else
            {
                newChildNode = new NamedUriRequestHandlerNode(uri, method, handler);
            }

            ChildNodes.Add(newChildNode);

            ChildNodes = ChildNodes.OrderBy(n => n.GetSearchPriority()).ToList();
        }
예제 #29
0
        /// <summary>
        /// Метод добавления потомка к текущему узлу
        /// </summary>
        /// <param name="child">Потомок</param>
        public FileViewModel AddChild(FileViewModel child)
        {
            if (child != null)
            {
                ChildNodes.Add(child);
            }

            return(this);
        }
예제 #30
0
 public void AddChild(XmlNode node)
 {
     ChildNodes.Add(node);
     FirstChild = node;
     if (node.NodeType == XmlNodeType.Element)
     {
         FirstElement = node;
     }
 }