/// <summary> /// Create a new command data query object from the data object. /// </summary> /// <param name="name">The name of the command.</param> /// <param name="commandData">The command data object describing the command.</param> protected CommandData(string name, Data.CommandData commandData) { _commandData = commandData; Name = name; var parameters = new Dictionary <string, ParameterData>(StringComparer.OrdinalIgnoreCase); var paramAliases = new Dictionary <string, ParameterData>(StringComparer.OrdinalIgnoreCase); if (commandData.Parameters != null) { foreach (KeyValuePair <string, Microsoft.PowerShell.CrossCompatibility.Data.ParameterData> parameter in commandData.Parameters) { parameters.Add(parameter.Key, new ParameterData(parameter.Key, parameter.Value)); } } if (commandData.ParameterAliases != null) { foreach (KeyValuePair <string, string> parameterAlias in commandData.ParameterAliases) { paramAliases.Add(parameterAlias.Key, parameters[parameterAlias.Value]); } } foreach (KeyValuePair <string, ParameterData> parameterAlias in paramAliases) { if (!parameters.ContainsKey(parameterAlias.Key)) { parameters.Add(parameterAlias.Key, parameterAlias.Value); } } Parameters = parameters; ParameterAliases = paramAliases; }
/// <summary> /// Create a new command data query object from the data object. /// </summary> /// <param name="name">The name of the command.</param> /// <param name="commandData">The command data object describing the command.</param> protected CommandData(string name, Data.CommandData commandData) { Name = name; DefaultParameterSet = commandData.DefaultParameterSet; if (commandData.OutputType != null) { OutputType = new List <string>(commandData.OutputType); } if (commandData.ParameterSets != null) { ParameterSets = new List <string>(commandData.ParameterSets); } var parameters = new Dictionary <string, ParameterData>(StringComparer.OrdinalIgnoreCase); var paramAliases = new Dictionary <string, ParameterData>(StringComparer.OrdinalIgnoreCase); if (commandData.Parameters != null) { foreach (KeyValuePair <string, Data.ParameterData> parameter in commandData.Parameters) { parameters.Add(parameter.Key, new ParameterData(parameter.Key, parameter.Value)); } } if (commandData.ParameterAliases != null) { foreach (KeyValuePair <string, string> parameterAlias in commandData.ParameterAliases) { paramAliases.Add(parameterAlias.Key, parameters[parameterAlias.Value]); } } foreach (KeyValuePair <string, ParameterData> parameterAlias in paramAliases) { if (!parameters.ContainsKey(parameterAlias.Key)) { parameters.Add(parameterAlias.Key, parameterAlias.Value); } } Parameters = parameters; ParameterAliases = paramAliases; }