Condividi tramite


SubscriptionEnumeration.GetEnumerator Method

Gets an IEnumerator interface that allows you to iterate through the collection of subscriptions represented by the SubscriptionEnumeration object.

Spazio dei nomi: Microsoft.SqlServer.NotificationServices
Assembly : Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)

Sintassi

'Dichiarazione
Public Function GetEnumerator As IEnumerator
public IEnumerator GetEnumerator ()
public:
virtual IEnumerator^ GetEnumerator () sealed
public final IEnumerator GetEnumerator ()
public final function GetEnumerator () : IEnumerator

Valore restituito

An IEnumerator interface for the SubscriptionEnumeration object.

Osservazioni

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.

Esempio

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);
}         

Thread Safety

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.

Piattaforme

Piattaforme di sviluppo

Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.

Piattaforme di destinazione

Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.

Vedere anche

Riferimento

SubscriptionEnumeration Class
SubscriptionEnumeration Members
Microsoft.SqlServer.NotificationServices Namespace