public ForeachObjectBuilder(ForeachObjectNode foreachobjectnode) { node = foreachobjectnode; DotDefinition = new List <IDotElement>(); CreateNode(); CreateEdgeToFirstChildren(); CreateEndNode(); CreateLoopEdge(); CreateEdgeToNextSibling(); }
// ContinueStatementAst Extension Methods // New Methods Available: // - CreateNodeFromAST(NodeDepth, NodePosition, Parent) => Creates a Node public static ForeachObjectNode CreateNodeFromAst(this PipelineAst _ast, int _depth, int _position, Node _parent, Tree _tree) { string pattern = @"(?i)%|foreach|foreach-object"; Regex rgx = new Regex(pattern); ForeachObjectNode node = null; foreach (var item in _ast.PipelineElements) { if (item is CommandAst) { CommandAst CastedItem = (CommandAst)item; if (rgx.IsMatch(CastedItem.GetCommandName())) { var prout = CastedItem.CommandElements.Where(x => x is ScriptBlockExpressionAst); node = new ForeachObjectNode(_ast, _depth, _position, _parent, _tree, prout.ToList()[0]); break; } } } return(node); }