/// <summary> /// This method creates a dictionary key for a Using expression value that is bound to /// a thread job script block parameter. PowerShell version 5.0+ recognizes this and performs /// the correct Using parameter argument binding. /// </summary> /// <param name="usingAst">A using expression</param> /// <returns>Base64 encoded string as the key of the UsingExpressionAst</returns> private static string GetUsingExpressionKey(UsingExpressionAst usingAst) { string usingAstText = usingAst.ToString(); if (usingAst.SubExpression is VariableExpressionAst) { usingAstText = usingAstText.ToLowerInvariant(); } return(Convert.ToBase64String(Encoding.Unicode.GetBytes(usingAstText.ToCharArray()))); }
public override AstVisitAction VisitUsingExpression(UsingExpressionAst usingExpressionAst) { Console.WriteLine("Visited an UsingExpressionAst."); Console.WriteLine(" " + usingExpressionAst.ToString().Replace(Environment.NewLine, Environment.NewLine + " ")); return(AstVisitAction.Continue); }