/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using Dbg = System.Management.Automation.Diagnostics;
namespace System.Management.Automation.Host
{
///
///
/// Provides a description of a choice for use by .
///
///
///
public sealed
class ChoiceDescription
{
///
///
/// 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("label", DescriptionsStrings.NullOrEmptyErrorTemplate, "label");
}
_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("label", DescriptionsStrings.NullOrEmptyErrorTemplate, "label");
}
if (helpMessage == null)
{
// "helpMessage" is not localizable
throw PSTraceSource.NewArgumentNullException("helpMessage");
}
_label = label;
_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(_label != null, "label should not be null");
return _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(_helpMessage != null, "helpMessage should not be null");
return _helpMessage;
}
set
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
}
_helpMessage = value;
}
}
private readonly string _label = null;
private string _helpMessage = "";
}
}