IVsaCodeItem.AddEventSource(String, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds an event source to the code item. The code item uses the event source to hook up an event to the named event source by calling the IVsaSite.GetEventSourceInstance method, which is implemented by the host.
public:
void AddEventSource(System::String ^ eventSourceName, System::String ^ eventSourceType);
public void AddEventSource (string eventSourceName, string eventSourceType);
abstract member AddEventSource : string * string -> unit
Public Sub AddEventSource (eventSourceName As String, eventSourceType As String)
Parameters
- eventSourceName
- String
A programmatic name of the event source.
- eventSourceType
- String
The type name of the event source.
Remarks
The script engine uses information provided by the AddEventSource method to hook up events to the named event source. It obtains event sources by calling the IVsaSite.GetEventSourceInstance method, which is implemented by the host. The AddEventSource method creates a class that handles events raised by a host-provided object.
Note
The JScript .NET script engine does not support this method. In cases where the JScript .NET engine must hook up an event, you must do so using a global item. Rather than event sources, the JScript .NET engine uses AppGlobal item types. For more information, see VsaItemType.
Within the code item, you can access the event source object by name, and, once accessed, you can write event handlers against the object. The event source type is passed as a string rather than as a Type object to facilitate implementing event sources by unmanaged hosts.
The compiler uses the eventSourceType parameter to bind to methods provided by the type. It is also used later when the script engine calls the IVsaSite.GetEventSourceInstance method to request an instance of the Type object.
For more information about the mechanisms for hooking up events for the script engine, see the IVsaSite.GetEventSourceInstance method.