Share via


EnumerableComCollection<TComEnumerator,TEnumerated> Class

Definition

Generic base class for types that provide an IEnumerable wrapper around COM-style IEnumXXX interfaces.

generic <typename TComEnumerator, typename TEnumerated>
public ref class EnumerableComCollection abstract : Microsoft::VisualStudio::Shell::IComEnumeratorRelay<TComEnumerator, TEnumerated>, System::Collections::Generic::IEnumerable<TEnumerated>
public abstract class EnumerableComCollection<TComEnumerator,TEnumerated> : Microsoft.VisualStudio.Shell.IComEnumeratorRelay<TComEnumerator,TEnumerated>, System.Collections.Generic.IEnumerable<TEnumerated>
type EnumerableComCollection<'ComEnumerator, 'Enumerated> = class
    interface seq<'Enumerated>
    interface IEnumerable
    interface IComEnumeratorRelay<'ComEnumerator, 'Enumerated>
Public MustInherit Class EnumerableComCollection(Of TComEnumerator, TEnumerated)
Implements IComEnumeratorRelay(Of TComEnumerator, TEnumerated), IEnumerable(Of TEnumerated)

Type Parameters

TComEnumerator

COM enumerator type (e.g. IEnumString)

TEnumerated

Type enumerated by TComEnumerator (e.g. string)

Inheritance
EnumerableComCollection<TComEnumerator,TEnumerated>
Derived
Implements

Remarks

Classes that derive from this class adapt a COM-style IEnumXXX interface into an form that can be processed by a foreach statement. Ideally this generic class would be sufficient on its own without the need for a derived class to do the job, but the rigor with which C# generics must be defined prevents that.

This class must call methods on the COM enumerator that it wraps (Next, Skip, etc.), but generic types can only access properties and methods on their parameterized types that are specified in the parameterized types' constraints. Specifically, we can only call TComEnumerator.Next if we specify a constraint on TComEnumerator that tells the compiler that TComEnumerator implements Next.

COM IEnumXXX interfaces are strongly typed (i.e. IEnumXXX.Next returns an array of XXX objects) and do not have a common base class, so we can't place a constraint on TComEnumerator directly. This is where IComEnumeratorRelay comes in: EnumerableComCollection requires that its derived class implements the strongly-typed IComEnumeratorRelay interface which allows the generic type to call into the COM enumerator without having to place a constraint on TComEnumerator.

Constructors

EnumerableComCollection<TComEnumerator,TEnumerated>(TComEnumerator, Int32)

Initializes a new instance of EnumerableComCollection<TComEnumerator,TEnumerated> for the provided enumerator and cache size.

EnumerableComCollection<TComEnumerator,TEnumerated>(TComEnumerator)

Initializes a new instance of EnumerableComCollection<TComEnumerator,TEnumerated> for the provided enumerator.

Fields

DefaultCacheSize

The default cache size.

Methods

Clone(TComEnumerator, TComEnumerator)

Clones the item with the specified enumerator .

GetEnumerator()

Gets the enumerator.

NextItems(TComEnumerator, UInt32, TEnumerated[], UInt32)

Gets the specified number of items.

Reset(TComEnumerator)

Resets the counter of the collection.

Skip(TComEnumerator, UInt32)

Skips the specified number of items.

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Gets the enumerator.

Extension Methods

EmptyIfNull<T>(IEnumerable<T>)

Return this enumeration in case it is not null. In case it is null return empty enumeration.

Applies to