Partager via


IVsContainedLanguageCodeSupport.EnsureEventHandler Method

Creates an event handler given the class context, name of the object instance, name of the event, and the (unique) name of event handler, if none exists already.

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)

Syntax

'Declaration
Function EnsureEventHandler ( _
    pszClassName As String, _
    pszObjectTypeName As String, _
    pszNameOfEvent As String, _
    pszEventHandlerName As String, _
    itemidInsertionPoint As UInteger, _
    <OutAttribute> ByRef pbstrUniqueMemberID As String, _
    <OutAttribute> ByRef pbstrEventBody As String, _
    <OutAttribute> pSpanInsertionPoint As TextSpan() _
) As Integer
int EnsureEventHandler(
    string pszClassName,
    string pszObjectTypeName,
    string pszNameOfEvent,
    string pszEventHandlerName,
    uint itemidInsertionPoint,
    out string pbstrUniqueMemberID,
    out string pbstrEventBody,
    TextSpan[] pSpanInsertionPoint
)
int EnsureEventHandler(
    [InAttribute] String^ pszClassName, 
    [InAttribute] String^ pszObjectTypeName, 
    [InAttribute] String^ pszNameOfEvent, 
    [InAttribute] String^ pszEventHandlerName, 
    [InAttribute] unsigned int itemidInsertionPoint, 
    [OutAttribute] String^% pbstrUniqueMemberID, 
    [OutAttribute] String^% pbstrEventBody, 
    [OutAttribute] array<TextSpan>^ pSpanInsertionPoint
)
abstract EnsureEventHandler : 
        pszClassName:string * 
        pszObjectTypeName:string * 
        pszNameOfEvent:string * 
        pszEventHandlerName:string * 
        itemidInsertionPoint:uint32 * 
        pbstrUniqueMemberID:string byref * 
        pbstrEventBody:string byref * 
        pSpanInsertionPoint:TextSpan[] byref -> int
function EnsureEventHandler(
    pszClassName : String, 
    pszObjectTypeName : String, 
    pszNameOfEvent : String, 
    pszEventHandlerName : String, 
    itemidInsertionPoint : uint, 
    pbstrUniqueMemberID : String, 
    pbstrEventBody : String, 
    pSpanInsertionPoint : TextSpan[]
) : int

Parameters

  • pszEventHandlerName
    Type: System.String

    [in] Name of the event handler.

  • pbstrUniqueMemberID
    Type: System.String%

    [out] Returns a unique member ID for the event handler.

  • pbstrEventBody
    Type: System.String%

    [out] Returns the returned event handler body.

Return Value

Type: System.Int32
If successful, returns S_OK; otherwise, returns an error code.

Remarks

COM Signature

From singlefileeditor.idl:

HRESULT EnsureEventHandler(
   [in]  LPCWSTR   pszClassName,
   [in]  LPCWSTR   pszObjectTypeName,
   [in]  LPCWSTR   pszNameOfEvent,
   [in]  LPCWSTR   pszEventHandlerName,
   [in]  VSITEMID  itemidInsertionPoint,
   [out] BSTR*     pbstrUniqueMemberID,
   [out] BSTR*     pbstrEventBody,
   [out] TextSpan* pSpanInsertionPoint
);

This method returns the entire event handler body and a string representation that uniquely identifies the event member within the given class context. In the case where the event handler already exists, the unique member ID of that class member is returned with a null string for both the event body and member ID.

The itemidInsertionPoint parameter indicates the file/buffer where the designer would like to put a new method. If the method does not exist then the insertion point returned in the pSpanInsertionPoint parameter is for the buffer of the requested itemid.

Note that this method does not inject the generated event handler into the secondary buffer or partial class file, only into the primary buffer.

.NET Framework Security

See Also

Reference

IVsContainedLanguageCodeSupport Interface

Microsoft.VisualStudio.TextManager.Interop Namespace