CommandParameterCollection Class

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)

'Usage
Dim instance As CommandParameterCollection

public sealed class CommandParameterCollection : Collection<CommandParameter>
public final class CommandParameterCollection extends Collection<CommandParameter>
public final class CommandParameterCollection extends Collection<CommandParameter>

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;
        }

System.Object
   System.Collections.ObjectModel.Collection
    System.Management.Automation.Runspaces.CommandParameterCollection

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

 

Target Platforms


Show:
© 2015 Microsoft