forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWrite-Object.cs
More file actions
60 lines (53 loc) · 1.74 KB
/
Copy pathWrite-Object.cs
File metadata and controls
60 lines (53 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Management.Automation;
namespace Microsoft.PowerShell.Commands
{
#region WriteOutputCommand
/// <summary>
/// This class implements Write-Output command.
/// </summary>
[Cmdlet(VerbsCommunications.Write, "Output", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=113427", RemotingCapability = RemotingCapability.None)]
public sealed class WriteOutputCommand : PSCmdlet
{
private PSObject[] _inputObjects = null;
/// <summary>
/// Holds the list of objects to be written.
/// </summary>
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromRemainingArguments = true)]
[AllowNull]
[AllowEmptyCollection]
public PSObject[] InputObject
{
get { return _inputObjects; }
set { _inputObjects = value; }
}
/// <summary>
/// Prevents Write-Output from unravelling collections passed to the InputObject parameter.
/// </summary>
[Parameter()]
public SwitchParameter NoEnumerate
{
get;
set;
}
/// <summary>
/// This method implements the ProcessRecord method for Write-output command.
/// </summary>
protected override void ProcessRecord()
{
if (_inputObjects == null)
{
WriteObject(_inputObjects);
return;
}
bool enumerate = true;
if (NoEnumerate.IsPresent)
{
enumerate = false;
}
WriteObject(_inputObjects, enumerate);
}
}
#endregion
}