/// <summary> /// Adds the help parameters segment /// </summary> /// <param name="setting">true if it should add the segment</param> /// <param name="sectionTitle">title of the section</param> /// <param name="paramPropertyName">name of the property which has properties</param> /// <param name="helpCategory">category of help</param> private void AddParameters(bool setting, string sectionTitle, string paramPropertyName, HelpCategory helpCategory) { if (!setting) { return; } PSObject parameterRootObject = HelpParagraphBuilder.GetPropertyObject(this.psObj, paramPropertyName) as PSObject; if (parameterRootObject == null) { return; } object[] parameterObjects = null; //Root object for Class has members not parameters. if (helpCategory != HelpCategory.Class) { parameterObjects = HelpParagraphBuilder.GetPropertyObjectArray(parameterRootObject, "parameter"); } if (parameterObjects == null || parameterObjects.Length == 0) { return; } this.AddText(sectionTitle, true); this.AddText("\r\n", false); foreach (object parameterObj in parameterObjects) { PSObject parameter = parameterObj as PSObject; if (parameter == null) { continue; } string parameterValue = GetPropertyString(parameter, "parameterValue"); string name = GetPropertyString(parameter, "name"); string description = GetTextFromArray(parameter, "description"); string required = GetPropertyString(parameter, "required"); string position = GetPropertyString(parameter, "position"); string pipelineinput = GetPropertyString(parameter, "pipelineInput"); string defaultValue = GetPropertyString(parameter, "defaultValue"); string acceptWildcard = GetPropertyString(parameter, "globbing"); if (String.IsNullOrEmpty(name)) { continue; } // This syntax string is not localized if (helpCategory == HelpCategory.DscResource) { this.AddText(HelpParagraphBuilder.AddIndent(""), false); } else { this.AddText(HelpParagraphBuilder.AddIndent("-"), false); } this.AddText(name, true); string parameterText = String.Format( CultureInfo.CurrentCulture, " <{0}>\r\n", parameterValue); this.AddText(parameterText, false); if (description != null) { this.AddText(HelpParagraphBuilder.AddIndent(description, 2), false); this.AddText("\r\n", false); } this.AddText("\r\n", false); int largestSize = HelpParagraphBuilder.LargestSize( HelpWindowResources.ParameterRequired, HelpWindowResources.ParameterPosition, HelpWindowResources.ParameterDefautValue, HelpWindowResources.ParameterPipelineInput, HelpWindowResources.ParameterAcceptWildcard); // justification of parameter values is not localized string formatString = String.Format( CultureInfo.CurrentCulture, "{{0,-{0}}}{{1}}", largestSize + 2); string tableLine; tableLine = String.Format( CultureInfo.CurrentCulture, formatString, HelpWindowResources.ParameterRequired, required); this.AddText(HelpParagraphBuilder.AddIndent(tableLine, 2), false); this.AddText("\r\n", false); //these are not applicable for Dsc Resource help if (helpCategory != HelpCategory.DscResource) { tableLine = String.Format( CultureInfo.CurrentCulture, formatString, HelpWindowResources.ParameterPosition, position); this.AddText(HelpParagraphBuilder.AddIndent(tableLine, 2), false); this.AddText("\r\n", false); tableLine = String.Format( CultureInfo.CurrentCulture, formatString, HelpWindowResources.ParameterDefautValue, defaultValue); this.AddText(HelpParagraphBuilder.AddIndent(tableLine, 2), false); this.AddText("\r\n", false); tableLine = String.Format( CultureInfo.CurrentCulture, formatString, HelpWindowResources.ParameterPipelineInput, pipelineinput); this.AddText(HelpParagraphBuilder.AddIndent(tableLine, 2), false); this.AddText("\r\n", false); tableLine = String.Format( CultureInfo.CurrentCulture, formatString, HelpWindowResources.ParameterAcceptWildcard, acceptWildcard); this.AddText(HelpParagraphBuilder.AddIndent(tableLine, 2), false); } this.AddText("\r\n\r\n", false); } this.AddText("\r\n\r\n", false); }