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
65 lines (59 loc) · 2.03 KB
/
Copy pathWrite-Object.cs
File metadata and controls
65 lines (59 loc) · 2.03 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
61
62
63
64
65
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
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 (null == _inputObjects)
{
WriteObject(_inputObjects);
return;
}
bool enumerate = true;
if (NoEnumerate.IsPresent)
{
enumerate = false;
}
foreach (PSObject inputObject in _inputObjects) // compensate for ValueFromRemainingArguments
{
WriteObject(inputObject, enumerate);
}
}//processrecord
}//WriteOutputCommand
#endregion
}