// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Dbg = System.Management.Automation.Diagnostics; namespace System.Management.Automation.Host { /// /// Provides a description of a choice for use by . /// /// public sealed class ChoiceDescription { #region DO NOT REMOVE OR RENAME THESE FIELDS - it will break remoting compatibility with Windows PowerShell compatibility with Windows PowerShell private readonly string label = null; private string helpMessage = string.Empty; #endregion /// /// Initializes an new instance of ChoiceDescription and defines the Label value. /// /// /// The label to identify this field description /// /// /// is null or empty. /// public ChoiceDescription(string label) { // the only required parameter is label. if (string.IsNullOrEmpty(label)) { // "label" is not localizable throw PSTraceSource.NewArgumentException(nameof(label), DescriptionsStrings.NullOrEmptyErrorTemplate, "label"); } this.label = label; } /// /// Initializes an new instance of ChoiceDescription and defines the Label and HelpMessage values. /// /// /// The label to identify this field description. /// /// /// The help message for this field. /// /// /// is null or empty. /// /// /// is null. /// public ChoiceDescription(string label, string helpMessage) { // the only required parameter is label. if (string.IsNullOrEmpty(label)) { // "label" is not localizable throw PSTraceSource.NewArgumentException(nameof(label), DescriptionsStrings.NullOrEmptyErrorTemplate, "label"); } if (helpMessage == null) { // "helpMessage" is not localizable throw PSTraceSource.NewArgumentNullException(nameof(helpMessage)); } this.label = label; this.helpMessage = helpMessage; } /// /// Gets a short, human-presentable message to describe and identify the choice. Think Button label. /// /// /// Note that the special character & (ampersand) may be embedded in the label string to identify the next character in the label /// as a "hot key" (aka "keyboard accelerator") that the Console.PromptForChoice implementation may use to allow the user to /// quickly set input focus to this choice. The implementation of /// is responsible for parsing the label string for this special character and rendering it accordingly. /// /// For examples, a choice named "Yes to All" might have "Yes to &All" as it's label. /// public string Label { get { Dbg.Assert(this.label != null, "label should not be null"); return this.label; } } /// /// Gets and sets the help message for this field. /// /// /// Set to null. /// /// /// This should be a few sentences to describe the field, suitable for presentation as a tool tip. /// Avoid placing including formatting characters such as newline and tab. /// public string HelpMessage { get { Dbg.Assert(this.helpMessage != null, "helpMessage should not be null"); return this.helpMessage; } set { if (value == null) { throw PSTraceSource.NewArgumentNullException("value"); } this.helpMessage = value; } } } }