forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowCommandParameterSetInfo.cs
More file actions
73 lines (64 loc) · 2.58 KB
/
Copy pathShowCommandParameterSetInfo.cs
File metadata and controls
73 lines (64 loc) · 2.58 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
66
67
68
69
70
71
72
73
//-----------------------------------------------------------------------
// Copyright © Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
/// <summary>
/// Implements a facade around CommandParameterSetInfo and its deserialized counterpart
/// </summary>
public class ShowCommandParameterSetInfo
{
/// <summary>
/// Creates an instance of the ShowCommandParameterSetInfo class based on a CommandParameterSetInfo object
/// </summary>
///
/// <param name="other">
/// The object to wrap.
/// </param>
public ShowCommandParameterSetInfo(CommandParameterSetInfo other)
{
if (null == other)
{
throw new ArgumentNullException("other");
}
this.Name = other.Name;
this.IsDefault = other.IsDefault;
this.Parameters = other.Parameters.Select(x => new ShowCommandParameterInfo(x)).ToArray();
}
/// <summary>
/// Creates an instance of the ShowCommandParameterSetInfo class based on a PSObject object
/// </summary>
///
/// <param name="other">
/// The object to wrap.
/// </param>
public ShowCommandParameterSetInfo(PSObject other)
{
if (null == other)
{
throw new ArgumentNullException("other");
}
this.Name = other.Members["Name"].Value as string;
this.IsDefault = (bool)(other.Members["IsDefault"].Value);
var parameters = (other.Members["Parameters"].Value as PSObject).BaseObject as System.Collections.ArrayList;
this.Parameters = ShowCommandCommandInfo.GetObjectEnumerable(parameters).Cast<PSObject>().Select(x => new ShowCommandParameterInfo(x)).ToArray();
}
/// <summary>
/// Gets the name of the parameter set
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Gets whether the parameter set is the default parameter set.
/// </summary>
public bool IsDefault { get; private set; }
/// <summary>
/// Gets the parameter information for the parameters in this parameter set.
/// </summary>
public ICollection<ShowCommandParameterInfo> Parameters { get; private set; }
}
}