IVsaCodeItem.AddEventSource Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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.

Namespace:  Microsoft.Vsa
Assembly:  Microsoft.Vsa (in Microsoft.Vsa.dll)

Syntax

'Declaration
<PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")> _
Sub AddEventSource ( _
    eventSourceName As String, _
    eventSourceType As String _
)
[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
void AddEventSource(
    string eventSourceName,
    string eventSourceType
)
[PermissionSetAttribute(SecurityAction::LinkDemand, Name = L"FullTrust")]
void AddEventSource(
    String^ eventSourceName, 
    String^ eventSourceType
)
[<PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")>]
abstract AddEventSource : 
        eventSourceName:string * 
        eventSourceType:string -> unit
function AddEventSource(
    eventSourceName : String, 
    eventSourceType : String
)

Parameters

  • eventSourceName
    Type: System.String

    A programmatic name of the event source.

  • eventSourceType
    Type: System.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.

See Also

Reference

IVsaCodeItem Interface

Microsoft.Vsa Namespace