Application.HostedEventProviders Property

Gets a HostedEventProviderCollection object, which contains the set of hosted event providers for the Notification Services application.

Namespace: Microsoft.SqlServer.Management.Nmo
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

Syntax

'Declaration
Public ReadOnly Property HostedEventProviders As HostedEventProviderCollection
public HostedEventProviderCollection HostedEventProviders { get; }
public:
property HostedEventProviderCollection^ HostedEventProviders {
    HostedEventProviderCollection^ get ();
}
/** @property */
public HostedEventProviderCollection get_HostedEventProviders ()
public function get HostedEventProviders () : HostedEventProviderCollection

Property Value

A HostedEventProviderCollection object.

Remarks

Hosted event providers are event collection components that are hosted by the Notification Services engine and submit events to the application. An application can have zero or more hosted event providers. An application can also use non-hosted event providers.

Use the methods of the HostedEventProviderCollection class to add or remove HostedEventProvider objects.

Example

The following examples show how to define a hosted event provider and add it to an application using this HostedEventProviders property:

// Define a hosted event provider
HostedEventProvider flightEventProvider = 
    new HostedEventProvider(myApplication, "FlightEP");
flightEventProvider.ClassName = "FileSystemWatcherProvider";
flightEventProvider.SystemName = notificationServicesHost;

// Define event provider arguments
HostedEventProviderArgument fileArg_Directory = 
    new HostedEventProviderArgument(
    flightEventProvider, "WatchDirectory");
fileArg_Directory.Value = sampleDirectory + @"\Events";
flightEventProvider.HostedEventProviderArguments.Add(
    fileArg_Directory);

HostedEventProviderArgument fileArg_Schema = 
    new HostedEventProviderArgument(
    flightEventProvider, "SchemaFile");
fileArg_Schema.Value = sampleDirectory + 
    @"\AppDefinition\EventsSchema.xsd";
flightEventProvider.HostedEventProviderArguments.Add(
    fileArg_Schema);

HostedEventProviderArgument fileArg_EventClass = 
    new HostedEventProviderArgument(flightEventProvider, 
    "EventClassName");
fileArg_EventClass.Value = "FlightEvents";
flightEventProvider.HostedEventProviderArguments.Add(
    fileArg_EventClass);

myApplication.HostedEventProviders.Add(flightEventProvider);
' Define a hosted event provider
Dim flightEventProvider As HostedEventProvider = _
    New HostedEventProvider(myApplication, "FlightEP")
flightEventProvider.ClassName = "FileSystemWatcherProvider"
flightEventProvider.SystemName = notificationServicesHost

' Define event provider arguments
Dim fileArg_Directory As HostedEventProviderArgument = _
    New HostedEventProviderArgument(flightEventProvider, _
        "WatchDirectory")
fileArg_Directory.Value = sampleDirectory + "\Events"
flightEventProvider.HostedEventProviderArguments.Add( _
    fileArg_Directory)

Dim fileArg_Schema As HostedEventProviderArgument = _
    New HostedEventProviderArgument(flightEventProvider, _
        "SchemaFile")
fileArg_Schema.Value = sampleDirectory + _
    "\AppDefinition\EventsSchema.xsd"
flightEventProvider.HostedEventProviderArguments.Add( _
    fileArg_Schema)

Dim fileArg_EventClass As HostedEventProviderArgument = _
    New HostedEventProviderArgument(flightEventProvider, _
    "EventClassName")
fileArg_EventClass.Value = "FlightEvents"
flightEventProvider.HostedEventProviderArguments.Add( _
    fileArg_EventClass)

myApplication.HostedEventProviders.Add(flightEventProvider)

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

Application Class
Application Members
Microsoft.SqlServer.Management.Nmo Namespace
NonHostedEventProviders

Other Resources

Defining Event Providers
Providers Element (ADF)