EnumerableComCollection<TComEnumerator, TEnumerated> Class
Provides a generic base class for types that provide an IEnumerable wrapper around COM-style IEnumXXX interfaces.
Inheritance Hierarchy
System.Object
Microsoft.VisualStudio.Shell.EnumerableComCollection<TComEnumerator, TEnumerated>
Microsoft.Internal.VisualStudio.PlatformUI.EnumerablePropertiesCollection
Microsoft.Internal.VisualStudio.PlatformUI.EnumerableVerbsCollection
Microsoft.VisualStudio.Shell.EnumerableHierarchiesCollection
Namespace: Microsoft.VisualStudio.Shell
Assembly: Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)
Syntax
'Declaração
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>
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 | |
---|---|---|
EnumerableComCollection<TComEnumerator, TEnumerated>(TComEnumerator) | Initializes a new instance of EnumerableComCollection<TComEnumerator, TEnumerated> for the provided enumerator. | |
EnumerableComCollection<TComEnumerator, TEnumerated>(TComEnumerator, Int32) | Initializes a new instance of EnumerableComCollection<TComEnumerator, TEnumerated> for the provided enumerator and cache size. |
Top
Methods
Name | Description | |
---|---|---|
Clone | Clones the item with the specified enumerator . | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetEnumerator | Gets the enumerator. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
NextItems | Gets the specified number of items. | |
Reset | Resets the counter of the collection. | |
Skip | Skips the specified number of items. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Fields
Name | Description | |
---|---|---|
DefaultCacheSize | The default cache size. |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
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.