Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CommandParameterCollection Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Represents a collection of command parameters. This class cannot be inherited.

Namespace:   System.Management.Automation.Runspaces
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

System.Object
  System.Collections.ObjectModel.Collection<T>
    System.Management.Automation.Runspaces.CommandParameterCollection

public sealed class CommandParameterCollection : Collection<CommandParameter>

NameDescription
System_CAPS_pubmethodCommandParameterCollection()

Initializes a new instance of the CommandParameterCollection class. Introduced in Windows PowerShell 3.0.

NameDescription
System_CAPS_pubpropertyCount

(Inherited from Collection<T>.)

System_CAPS_pubpropertyItem[Int32]

(Inherited from Collection<T>.)

NameDescription
System_CAPS_pubmethodAdd(T)

(Inherited from Collection<T>.)

System_CAPS_pubmethodAdd(String)

Adds a named parameter with a null value to the parameter collection.

System_CAPS_pubmethodAdd(String, Object)

Adds a named parameter with a value to the parameter collection.

System_CAPS_pubmethodClear()

(Inherited from Collection<T>.)

System_CAPS_pubmethodContains(T)

(Inherited from Collection<T>.)

System_CAPS_pubmethodCopyTo(T[], Int32)

(Inherited from Collection<T>.)

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

(Inherited from Collection<T>.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIndexOf(T)

(Inherited from Collection<T>.)

System_CAPS_pubmethodInsert(Int32, T)

(Inherited from Collection<T>.)

System_CAPS_pubmethodRemove(T)

(Inherited from Collection<T>.)

System_CAPS_pubmethodRemoveAt(Int32)

(Inherited from Collection<T>.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

The following code sample, pulled from the jobsourceadaptersample in the PowerShell SDK, uses the CommandParameterCollection class to retrieve source and destination path information.

public override Job2 NewJob(JobInvocationInfo specification)
{
    if (specification == null)
    {
        throw new NullReferenceException("specification");
    }

    if (specification.Parameters.Count != 1)
    {
        throw new ArgumentException("JobInvocationInfo specification parameters not specified.");
    }

    // Retrieve source and destination path information from specification
    // parameters.
    string sourcePath = null;
    string destinationPath = null;
    CommandParameterCollection parameters = specification.Parameters[0];
    foreach (var item in parameters)
    {
        if (item.Name.Equals(SourcePathProperty, StringComparison.OrdinalIgnoreCase))
        {
            sourcePath = item.Value as string;
        }
        else if (item.Name.Equals(DestinationPathProperty, StringComparison.OrdinalIgnoreCase))
        {
            destinationPath = item.Value as string;
        }
    }

    // Create FileCopyJob
    FileCopyJob rtnJob = new FileCopyJob(specification.Name, sourcePath, destinationPath);
    lock (JobRepository)
    {
        JobRepository.Add(rtnJob);
    }
    return rtnJob;
}

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: