SubscriptionEnumeration.GetEnumerator Method
Gets an IEnumerator interface that allows you to iterate through the collection of subscriptions represented by the SubscriptionEnumeration object.
Espacio de nombres: Microsoft.SqlServer.NotificationServices
Ensamblado: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)
Sintaxis
'Declaración
Public Function GetEnumerator As IEnumerator
public IEnumerator GetEnumerator ()
public:
virtual IEnumerator^ GetEnumerator () sealed
public final IEnumerator GetEnumerator ()
public final function GetEnumerator () : IEnumerator
Valor devuelto
An IEnumerator interface for the SubscriptionEnumeration object.
Notas
Use this method to return an IEnumerator interface that allows you to iterate through the subscriptions in a SubscriptionEnumeration object. An initialized SubscriptionEnumeration object represents the collection of subscriptions of a particular subscription class for one subscriber in a specified Notification Services application.
Ejemplo
The following examples show how to use a SubscriptionEnumeration object to iterate through a set of subscriptions. The GetEnumerator method makes the For Each and foreach statements possible:
Dim instanceName As String = "MyInstanceName"
Dim applicationName As String = "MyApplicationName"
Dim subscriptionClassName As String = "MySubscriptionClassName"
Dim subscriberId As String = "MySubscriberID"
'Create an NSInstance object.
Dim myInstance As New NSInstance(instanceName)
'Create an NSApplication object.
Dim myApplication As New NSApplication(myInstance, applicationName)
'Create a SubscriptionEnumeration object.
Dim mySubscriptionEnumeration As _
New SubscriptionEnumeration(myApplication, _
subscriptionClassName, subscriberId)
'Iterate through the subscriptions.
Dim subscription As Subscription
For Each subscription In mySubscriptionEnumeration
Console.WriteLine("Subscription ID: {0}", _
subscription.SubscriptionId)
Next subscription
string instanceName = "MyInstanceName";
string applicationName = "MyApplicationName";
string subscriptionClassName = "MySubscriptionClassName";
string subscriberId = "MySubscriberID";
//Create an NSInstance object.
NSInstance myInstance = new NSInstance(instanceName);
//Create an NSApplication object.
NSApplication myApplication =
new NSApplication(myInstance, applicationName);
//Create a SubscriptionEnumeration object.
SubscriptionEnumeration mySubscriptionEnumeration =
new SubscriptionEnumeration(myApplication,
subscriptionClassName, subscriberId);
//Iterate through the subscriptions.
foreach (Subscription subscription
in mySubscriptionEnumeration)
{
Console.WriteLine("Subscription ID: {0}",
subscription.SubscriptionId);
}
Seguridad para subprocesos
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Plataformas
Plataformas de desarrollo
Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.
Plataformas de destino
Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.
Vea también
Referencia
SubscriptionEnumeration Class
SubscriptionEnumeration Members
Microsoft.SqlServer.NotificationServices Namespace