SubscriptionEnumeration.GetEnumerator Method
Gets an IEnumerator interface that allows you to iterate through the collection of subscriptions represented by the SubscriptionEnumeration object.
Namespace: Microsoft.SqlServer.NotificationServices
Assembly: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)
Syntax
'Declaration
Public Function GetEnumerator As IEnumerator
public IEnumerator GetEnumerator ()
public:
virtual IEnumerator^ GetEnumerator () sealed
public final IEnumerator GetEnumerator ()
public final function GetEnumerator () : IEnumerator
Return Value
An IEnumerator interface for the SubscriptionEnumeration object.
Remarks
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.
Example
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.
Platforms
Development Platforms
For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.
Target Platforms
For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.
See Also
Reference
SubscriptionEnumeration Class
SubscriptionEnumeration Members
Microsoft.SqlServer.NotificationServices Namespace