EnumerableComCollection<TComEnumerator, TEnumerated> Class

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

This API is not CLS-compliant. 

Inheritance Hierarchy

  Microsoft.VisualStudio.Shell.EnumerableComCollection<TComEnumerator, TEnumerated>

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)


<CLSCompliantAttribute(False)> _
Public MustInherit Class EnumerableComCollection(Of TComEnumerator, TEnumerated) _
    Implements IEnumerable(Of TEnumerated), IEnumerable,  _
    IComEnumeratorRelay(Of TComEnumerator, TEnumerated)
public abstract class EnumerableComCollection<TComEnumerator, TEnumerated> : IEnumerable<TEnumerated>, 
    IEnumerable, IComEnumeratorRelay<TComEnumerator, TEnumerated>
generic<typename TComEnumerator, typename TEnumerated>
public ref class EnumerableComCollection abstract : IEnumerable<TEnumerated>, 
    IEnumerable, IComEnumeratorRelay<TComEnumerator, TEnumerated>
type EnumerableComCollection<'TComEnumerator, 'TEnumerated> =  
        interface IEnumerable<'TEnumerated>
        interface IEnumerable
        interface IComEnumeratorRelay<'TComEnumerator, 'TEnumerated>
JScript does not support generic types or methods.

Type Parameters

  • TComEnumerator
    A COM enumerator type (e.g. IEnumString).
  • TEnumerated
    The type of the enumerator.

The EnumerableComCollection<TComEnumerator, TEnumerated> type exposes the following members.


  Name Description
Protected method EnumerableComCollection<TComEnumerator, TEnumerated>(TComEnumerator) Initializes a new instance of EnumerableComCollection<TComEnumerator, TEnumerated> for the provided enumerator.
Protected method EnumerableComCollection<TComEnumerator, TEnumerated>(TComEnumerator, Int32) Initializes a new instance of EnumerableComCollection<TComEnumerator, TEnumerated> for the provided enumerator and cache size.



  Name Description
Public method Clone Clones the item with the specified enumerator .
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetEnumerator Gets the enumerator.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method NextItems Gets the specified number of items.
Public method Reset Resets the counter of the collection.
Public method Skip Skips the specified number of items.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)



  Name Description
Protected fieldStatic member DefaultCacheSize The default cache size.


Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IEnumerable.GetEnumerator Gets the enumerator.



Classes that derive from this class change a COM-style IEnumXXX interface into a form that can be processed by a foreach statement. You must derive a separate class from this base class due to the way C# generics are defined.

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

COM IEnumXXX interfaces are strongly typed. In other words, the IEnumXXX.Next() method returns an array of XXX objects. Because these interfaces do not have a common base interface, you cannot place a constraint on TComEnumerator directly. You can solve this problem by implementing the IComEnumeratorRelay<TComEnumerator, TEnumerated> interface along with the EnumerableComCollection<TComEnumerator, TEnumerated> interface. Doing so allows the generic type to call into the COM enumerator without having to place a constraint on TComEnumerator.

Thread Safety

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

See Also


Microsoft.VisualStudio.Shell Namespace