HostedEventProviderCollection.Add Method
Adds an HostedEventProvider to the HostedEventProviderCollection.
命名空間: Microsoft.SqlServer.Management.Nmo
組件: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
語法
'宣告
Public Sub Add ( _
hostedEventProvider As HostedEventProvider _
)
public void Add (
HostedEventProvider hostedEventProvider
)
public:
void Add (
HostedEventProvider^ hostedEventProvider
)
public void Add (
HostedEventProvider hostedEventProvider
)
public function Add (
hostedEventProvider : HostedEventProvider
)
參數
- hostedEventProvider
The HostedEventProvider to add to the collection.
備註
Each event provider within an application must have a unique name.
If you add event providers after deploying the application, you must Update the instance to apply the changes.
範例
The following examples show how to define a hosted event provider and add it to an application:
// 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)
執行緒安全性
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.
平台
開發平台
如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。
目標平台
如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。
請參閱
參考
HostedEventProviderCollection Class
HostedEventProviderCollection Members
Microsoft.SqlServer.Management.Nmo Namespace