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.

PSDataCollection<T> Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

A thread safe buffer that is used by Windows PowerShell host applications to provide input data when invoking a pipeline of commands asynchronously. This class is introduced in Windows PowerShell 2.0.

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

System::Object
  System.Management.Automation::PSDataCollection<T>

generic<typename T>
[SerializableAttribute]
public ref class PSDataCollection : IList<T>, ICollection<T>, 
	IEnumerable<T>, IEnumerable, IList, ICollection, IDisposable, 
	ISerializable

Type Parameters

T

A type parameter that specifies the type of the data that is collected.

NameDescription
System_CAPS_pubmethodPSDataCollection<T>()

Creates a new PSDataCollection<T> object that is empty. This constructor is introduced by Windows PowerShell 2.0.

System_CAPS_pubmethodPSDataCollection<T>(IEnumerable<T>^)

Creates a new PSDataCollection<T> object that contains data for the input buffer, and calls the Complete method. This constructor is introduced by Windows PowerShell 2.0.

System_CAPS_pubmethodPSDataCollection<T>(Int32)

Creates a new PSDataCollection<T> object that specifies the number of items that the input buffer can contain without resizing the buffer. This constructor is introduced by Windows PowerShell 2.0.

System_CAPS_protmethodPSDataCollection<T>(SerializationInfo^, StreamingContext)

Initializes a new instance of the PSDataCollection<T> class from a serializable context. Introduced in Windows PowerShell 3.0.

NameDescription
System_CAPS_pubpropertyBlockingEnumerator

Gets or sets a value that indicates whether the data collection should have a blocking enumerator by default. Introduced in Windows PowerShell 3.0.

System_CAPS_pubpropertyCount

Gets the number of objects in the collection. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertyDataAddedCount

Gets or sets the number of times that data can be added before the DataAdded event is fired. Introduced in Windows PowerShell 3.0.

System_CAPS_pubpropertyEnumeratorNeverBlocks

Gets or sets a value that indicates whether the returned enumerator can never block. Introduced in Windows PowerShell 3.0.

System_CAPS_pubpropertyIsAutoGenerated

Gets or sets a value that indicates whether this PSDataCollection<T> was created implicitly in support of data collection. Introduced in Windows PowerShell 3.0.

System_CAPS_pubpropertyIsOpen

Gets a Boolean value that indicates whether the collection is available for adding objects. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertyIsReadOnly

Gets a Boolean value that indicates whether objects can only be retrieved from the collection. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertyItem[Int32]

Gets and sets an object at the specified location of the collection. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertySerializeInput

Gets or sets a value that indicates whether to serialize all input by default. Introduced in Windows PowerShell 3.0.

NameDescription
System_CAPS_pubmethodAdd(T)

Adds an object to the buffer. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodClear()

Removes all objects from the buffer. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodComplete()

Completes the process of adding content to the collection. This method must be called before the collection can be used to invoke a pipeline asynchronously. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodContains(T)

Determines whether the specified object is in the buffer. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodCopyTo(array<T>^, Int32)

Copies the contents of the buffer to an array, starting at the specified location. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodDispose()

Releases the resources that are used by the PSDataCollection<T> object. This method is introduced in Windows PowerShell 2.0.

System_CAPS_protmethodDispose(Boolean)

Releases the resources that are used by the PSDataCollection<T> object. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodEquals(Object^)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Retrieves an enumerator that can iterate through the objects in the buffer. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetObjectData(SerializationInfo^, StreamingContext)

Populates an object with the data needed to serialize the PSDataCollection<T>. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIndexOf(T)

Determines the index of the specified object in the buffer. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodInsert(Int32, T)

Inserts an object at the specified location. This method is introduced in Windows PowerShell 2.0.

System_CAPS_protmethodInsertItem(Guid, Int32, T)

Inserts an object into the buffer at the specified location. This method is introduced in Windows PowerShell 2.0.

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodReadAll()

Makes a shallow copy of items in the current collection and then clears the current collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodRemove(T)

Removes the first occurrence of the specified object from the buffer. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodRemoveAt(Int32)

Removes the object at the specified location. This method is introduced in Windows PowerShell 2.0.

System_CAPS_protmethodRemoveItem(Int32)

Removes the object at the specified location. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodToString()

(Inherited from Object.)

NameDescription
System_CAPS_pubeventCompleted

Event that is fired when the Complete method is called to indicate that no more data is to be added to the collection. This event is introduced in Windows PowerShell 2.0.

System_CAPS_pubeventDataAdded

Occurs after data is added to the collection. This event is introduced in Windows PowerShell 2.0.

System_CAPS_pubeventDataAdding

Occurs when objects are being added to the underlying buffer. Introduced in Windows PowerShell 3.0.

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticImplicit(T to PSDataCollection<T>^)

Wraps a type parameter argument in a PSDataCollection<T>. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(Boolean to PSDataCollection<T>^)

Wraps a Boolean argument in a PSDataCollection<T>. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(Byte to PSDataCollection<T>^)

Wraps a byte argument in a PSDataCollection<T>. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(Hashtable^ to PSDataCollection<T>^)

Wraps a hash table argument in a PSDataCollection<T>. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(Int32 to PSDataCollection<T>^)

Wraps an integer argument in a PSDataCollection<T>. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(array<Object^>^ to PSDataCollection<T>^)

Wraps an object array argument in a PSDataCollection<T>. Introduced in Windows PowerShell 3.0.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(String^ to PSDataCollection<T>^)

Wraps a string argument in a PSDataCollection<T>. Introduced in Windows PowerShell 3.0.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection::CopyTo(Array^, Int32)

Copies the elements of the collection to a specified array, starting at a specified index. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable::GetEnumerator()

Retrieves the IEnumerator interface that can be used to access the objects of the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList::Add(Object^)

Appends an object to the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList::Contains(Object^)

Determines whether an object exists in the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList::IndexOf(Object^)

Retrieves the location of an object in the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList::Insert(Int32, Object^)

Places an object at a specific location in the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList::Remove(Object^)

Deletes the first occurrence of an object from the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection::IsSynchronized

Gets a Boolean value that indicates whether the collection is synchronized. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection::SyncRoot

Gets the object used to synchronize access to the thread-safe collection. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList::IsFixedSize

Gets a Boolean value that indicates whether the size of the collection can be changed. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList::IsReadOnly

Gets a Boolean value that indicates whether objects cannot be added to the collection. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList::Item[Int32]

Gets and sets the object at the specified location in the collection. This property is introduced in Windows PowerShell 2.0.

When using this collection be sure to call the Complete method after adding data (as shown in the previous example). Windows PowerShell will continue to wait for more data until this call is made.

This collection is used for the input buffer for the following methods.

The following example shows how to add input data for the first command in the pipeline. In this case integers are added to the collection, and then those integers are sorted by the Sort-Object cmdlet.

// Create the data to be sorted by the Sort-Object cmdlet.
PSDataCollection<int> input =
    new PSDataCollection<int>();
input.Add(5);
input.Add(3);
input.Add(2);
input.Complete();

// Create an IAsyncResult object and call the
// BeginInvoke method to start running the 
// command pipeline asynchronously.
IAsyncResult async = ps.BeginInvoke<int>(input);

// Using the PowerShell.Invoke method, run the command
// pipeline using the default runspace.
foreach (PSObject result in ps.EndInvoke(async))
{
    Console.WriteLine(result);
} // End foreach.

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

Community Additions

Show: