2020-03-24 11:08:37 -07:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
2018-02-13 09:23:53 -08:00
|
|
|
// Licensed under the MIT License.
|
2016-03-30 14:20:52 -07:00
|
|
|
|
|
|
|
|
namespace System.Management.Automation
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A variable that represents $?
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal class QuestionMarkVariable : PSVariable
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs an instance of the variable with execution context.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="context">
|
|
|
|
|
/// Execution context
|
|
|
|
|
/// </param>
|
2016-07-29 13:02:49 -07:00
|
|
|
internal QuestionMarkVariable(ExecutionContext context)
|
2016-03-30 14:20:52 -07:00
|
|
|
: base(SpecialVariables.Question, true, ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope, RunspaceInit.DollarHookDescription)
|
|
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly ExecutionContext _context;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-01-16 13:31:14 -08:00
|
|
|
/// Gets or sets the value of the variable.
|
2016-03-30 14:20:52 -07:00
|
|
|
/// </summary>
|
|
|
|
|
public override object Value
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
DebuggerCheckVariableRead();
|
|
|
|
|
return _context.QuestionMarkVariableValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
// Call base's setter to force an error (because the variable is readonly).
|
|
|
|
|
base.Value = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-29 13:02:49 -07:00
|
|
|
}
|
|
|
|
|
}
|