//-----------------------------------------------------------------------
//
// Copyright © Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Management.Automation;
///
/// Implements a facade around CommandParameterSetInfo and its deserialized counterpart
///
public class ShowCommandParameterSetInfo
{
///
/// Creates an instance of the ShowCommandParameterSetInfo class based on a CommandParameterSetInfo object
///
///
///
/// The object to wrap.
///
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();
}
///
/// Creates an instance of the ShowCommandParameterSetInfo class based on a PSObject object
///
///
///
/// The object to wrap.
///
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().Select(x=>new ShowCommandParameterInfo(x)).ToArray();
}
///
/// Gets the name of the parameter set
///
public string Name { get; private set; }
///
/// Gets whether the parameter set is the default parameter set.
///
public bool IsDefault { get; private set; }
///
/// Gets the parameter information for the parameters in this parameter set.
///
public ICollection Parameters { get; private set; }
}
}