Share via


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

System.Object
  Microsoft.VisualStudio.Shell.EnumerableComCollection<TComEnumerator, TEnumerated>
    Microsoft.Internal.VisualStudio.PlatformUI.EnumerablePropertiesCollection
    Microsoft.Internal.VisualStudio.PlatformUI.EnumerableVerbsCollection

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

Syntax

'Declaration
<CLSCompliantAttribute(False)> _
Public MustInherit Class EnumerableComCollection(Of TComEnumerator, TEnumerated) _
    Implements IEnumerable(Of TEnumerated), IEnumerable,  _
    IComEnumeratorRelay(Of TComEnumerator, TEnumerated)
[CLSCompliantAttribute(false)]
public abstract class EnumerableComCollection<TComEnumerator, TEnumerated> : IEnumerable<TEnumerated>, 
    IEnumerable, IComEnumeratorRelay<TComEnumerator, TEnumerated>
[CLSCompliantAttribute(false)]
generic<typename TComEnumerator, typename TEnumerated>
public ref class EnumerableComCollection abstract : IEnumerable<TEnumerated>, 
    IEnumerable, IComEnumeratorRelay<TComEnumerator, TEnumerated>
[<AbstractClass>]
[<CLSCompliantAttribute(false)>]
type EnumerableComCollection<'TComEnumerator, 'TEnumerated> =  
    class
        interface IEnumerable<'TEnumerated>
        interface IEnumerable
        interface IComEnumeratorRelay<'TComEnumerator, 'TEnumerated>
    end
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.

Constructors

  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.

Top

Methods

  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.)

Top

Fields

  Name Description
Protected fieldStatic member DefaultCacheSize The default cache size.

Top

Explicit Interface Implementations

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

Top

Remarks

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

Reference

Microsoft.VisualStudio.Shell Namespace