IVsContainedLanguageStaticEventBinding.EnsureStaticEventHandler 方法

创建一个事件处理程序将类对象类型和实例上下文、名称,事件的名称和事件处理程序 (单值) 的名称。

命名空间:  Microsoft.VisualStudio.TextManager.Interop
程序集:  Microsoft.VisualStudio.TextManager.Interop.8.0(在 Microsoft.VisualStudio.TextManager.Interop.8.0.dll 中)

语法

声明
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

参数

  • pszClassName
    类型:String

    [in] 类的完全限定名。

  • pszObjectTypeName
    类型:String

    [in] 目标类型的完全限定名。

  • pszObjectName
    类型:String

    [in] 对象的名称。

  • pszNameOfEvent
    类型:String

    [in] 事件的名称。

  • pszEventHandlerName
    类型:String

    [in] 事件处理程序的名称。

  • pbstrUniqueMemberID
    类型:String%

    [out] 返回包含事件的成员 ID 的字符串。 ,如果已存在事件处理程序,则返回 null 值。

  • pbstrEventBody
    类型:String%

    [out] 返回包含事件处理程序的主体的字符串。 ,如果已存在事件处理程序,则返回 null 值。

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

    [in, out] 在事件处理程序主体在主缓冲区中插入的位置填充一 TextSpan 对象。 此插入点在 itemidInsertionPoint 参数指定的文件。 ,只有在事件处理程序已不存在,则有效。

返回值

类型:Int32
如果成功,则返回; S_OK否则,返回错误代码。

备注

COM 签名

从 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
);

如果已存在事件处理程序,此方法返回 S_OK ,并 pbstrEventBody 和 pbstrUniqueMemberID 参数返回空值,并 pSpanInsertionPoint 参数是未定义的。

仅注意此方法不插入生成的事件处理程序添加到辅助缓冲区或分部类文件,向主缓冲区。

.NET Framework 安全性

请参阅

参考

IVsContainedLanguageStaticEventBinding 接口

Microsoft.VisualStudio.TextManager.Interop 命名空间