System.Management.Pash.Implementation.ExecutionVisitor.SetMatchesVariable C# (CSharp) Method

SetMatchesVariable() private method

private SetMatchesVariable ( Regex regex, Match match ) : void
regex Regex
match Match
return void
        private void SetMatchesVariable(Regex regex, Match match)
        {
            var matches = new Hashtable();
            var groupNames = from name in regex.GetGroupNames()
                             where match.Groups[name].Success
                             select name;

            foreach (string name in groupNames)
            {
                int num;
                if (int.TryParse(name, out num))
                {
                    matches.Add(num, match.Groups[num].Value);
                }
                else
                {
                    matches.Add(name, match.Groups[name].Value);
                }
            }

            ExecutionContext.SetVariable("Matches", PSObject.AsPSObject(matches));
        }
ExecutionVisitor