Share via


IVsContainedLanguageStaticEventBinding.EnsureStaticEventHandler Method

Creates an event handler given the class context, name of the object type and instance, the name of the event and the (unique) name of the event handler.

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

Syntax

'Declaration
Function EnsureStaticEventHandler ( _
    pszClassName As String, _
    pszObjectTypeName As String, _
    pszObjectName 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 EnsureStaticEventHandler(
    string pszClassName,
    string pszObjectTypeName,
    string pszObjectName,
    string pszNameOfEvent,
    string pszEventHandlerName,
    uint itemidInsertionPoint,
    out string pbstrUniqueMemberID,
    out string pbstrEventBody,
    TextSpan[] pSpanInsertionPoint
)
int EnsureStaticEventHandler(
    [InAttribute] String^ pszClassName, 
    [InAttribute] String^ pszObjectTypeName, 
    [InAttribute] String^ pszObjectName, 
    [InAttribute] String^ pszNameOfEvent, 
    [InAttribute] String^ pszEventHandlerName, 
    [InAttribute] unsigned int itemidInsertionPoint, 
    [OutAttribute] String^% pbstrUniqueMemberID, 
    [OutAttribute] String^% pbstrEventBody, 
    [OutAttribute] array<TextSpan>^ pSpanInsertionPoint
)
abstract EnsureStaticEventHandler : 
        pszClassName:string * 
        pszObjectTypeName:string * 
        pszObjectName:string * 
        pszNameOfEvent:string * 
        pszEventHandlerName:string * 
        itemidInsertionPoint:uint32 * 
        pbstrUniqueMemberID:string byref * 
        pbstrEventBody:string byref * 
        pSpanInsertionPoint:TextSpan[] byref -> int
function EnsureStaticEventHandler(
    pszClassName : String, 
    pszObjectTypeName : String, 
    pszObjectName : String, 
    pszNameOfEvent : String, 
    pszEventHandlerName : String, 
    itemidInsertionPoint : uint, 
    pbstrUniqueMemberID : String, 
    pbstrEventBody : String, 
    pSpanInsertionPoint : TextSpan[]
) : int

Parameters

  • pszClassName
    Type: System.String

    [in] The fully qualified name of the class.

  • pszObjectTypeName
    Type: System.String

    [in] The fully qualified name of the object type.

  • pszEventHandlerName
    Type: System.String

    [in] The name of the event handler.

  • pbstrUniqueMemberID
    Type: System.String%

    [out] Returns a string containing the member ID of the event. Returns a null value if the event handler already exists.

  • pbstrEventBody
    Type: System.String%

    [out] Returns a string containing the body of the event handler. Returns a null value if the event handler already exists.

  • pSpanInsertionPoint
    Type: array<Microsoft.VisualStudio.TextManager.Interop.TextSpan[]

    [in, out] Fills in a TextSpan object with the position where the event handler body was inserted in the primary buffer. This insertion point is in the file specified by the itemidInsertionPoint parameter. This is valid only if the event handler did not already exist.

Return Value

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

Remarks

COM Signature

From singlefileeditor.idl:

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

If the event handler already exists, this method returns S_OK and the pbstrEventBody and pbstrUniqueMemberID parameters return null values and the pSpanInsertionPoint parameter is undefined.

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

IVsContainedLanguageStaticEventBinding Interface

Microsoft.VisualStudio.TextManager.Interop Namespace