private async Task <VariableContainerDetails> FetchVariableContainer( string scope, VariableContainerDetails autoVariables) { PSCommand psCommand = new PSCommand(); psCommand.AddCommand("Get-Variable"); psCommand.AddParameter("Scope", scope); var scopeVariableContainer = new VariableContainerDetails("Scope: " + scope); _variables.Add(scopeVariableContainer); var results = await ExecuteCommand <PSVariable>(psCommand); if (results != null) { foreach (PSVariable psvariable in results) { var variableDetails = new VariableDetails(psvariable); // { Id = this.nextVariableId++ }; _variables.Add(variableDetails); scopeVariableContainer.Children.Add(variableDetails); //.Add(variableDetails.Name, variableDetails); if ((autoVariables != null) && AddToAutoVariables(psvariable, scope)) { autoVariables.Children.Add(variableDetails); //(variableDetails.Name, variableDetails); } } } return(scopeVariableContainer); }
/// <summary> /// If this variable instance is expandable, this method returns the /// details of its children. Otherwise it returns an empty array. /// </summary> /// <returns></returns> public override VariableDetailsBase[] GetChildren() { VariableDetails[] childVariables = null; if (this.IsExpandable) { if (_cachedChildren == null) { _cachedChildren = GetChildren(_valueObject); } return _cachedChildren; } else { childVariables = new VariableDetails[0]; } return childVariables; }
/// <summary> /// If this variable instance is expandable, this method returns the /// details of its children. Otherwise it returns an empty array. /// </summary> /// <returns></returns> public override VariableDetailsBase[] GetChildren() { VariableDetails[] childVariables = null; if (this.IsExpandable) { if (_cachedChildren == null) { _cachedChildren = GetChildren(_valueObject); } return(_cachedChildren); } else { childVariables = new VariableDetails[0]; } return(childVariables); }