IVsContainedLanguageCodeSupport.EnsureEventHandler 方法

定义

如果类上下文、对象实例的名称、事件名称和事件处理程序的名称 (唯一) 名称,则创建事件处理程序(如果尚未存在)。

public:
 int EnsureEventHandler(System::String ^ pszClassName, System::String ^ pszObjectTypeName, System::String ^ pszNameOfEvent, System::String ^ pszEventHandlerName, System::UInt32 itemidInsertionPoint, [Runtime::InteropServices::Out] System::String ^ % pbstrUniqueMemberID, [Runtime::InteropServices::Out] System::String ^ % pbstrEventBody, cli::array <Microsoft::VisualStudio::TextManager::Interop::TextSpan> ^ pSpanInsertionPoint);
int EnsureEventHandler(std::wstring const & pszClassName, std::wstring const & pszObjectTypeName, std::wstring const & pszNameOfEvent, std::wstring const & pszEventHandlerName, unsigned int itemidInsertionPoint, [Runtime::InteropServices::Out] std::wstring const & & pbstrUniqueMemberID, [Runtime::InteropServices::Out] std::wstring const & & pbstrEventBody, std::Array <Microsoft::VisualStudio::TextManager::Interop::TextSpan> const & pSpanInsertionPoint);
public int EnsureEventHandler (string pszClassName, string pszObjectTypeName, string pszNameOfEvent, string pszEventHandlerName, uint itemidInsertionPoint, out string pbstrUniqueMemberID, out string pbstrEventBody, Microsoft.VisualStudio.TextManager.Interop.TextSpan[] pSpanInsertionPoint);
abstract member EnsureEventHandler : string * string * string * string * uint32 * string * string * Microsoft.VisualStudio.TextManager.Interop.TextSpan[] -> int
Public Function EnsureEventHandler (pszClassName As String, pszObjectTypeName As String, pszNameOfEvent As String, pszEventHandlerName As String, itemidInsertionPoint As UInteger, ByRef pbstrUniqueMemberID As String, ByRef pbstrEventBody As String, pSpanInsertionPoint As TextSpan()) As Integer

参数

pszClassName
String

中类的名称。

pszObjectTypeName
String

中对象的名称。

pszNameOfEvent
String

中事件的名称。

pszEventHandlerName
String

中事件处理程序的名称。

itemidInsertionPoint
UInt32

中设计器要在其中放置新方法的文件或缓冲区。 这是一个唯一标识符,也可以是以下值之一: VSITEMID_NILVSITEMID_ROOTVSITEMID_SELECTION

pbstrUniqueMemberID
String

弄返回事件处理程序的唯一成员 ID。

pbstrEventBody
String

弄返回返回的事件处理程序正文。

pSpanInsertionPoint
TextSpan[]

弄返回一个 TextSpan 对象,该对象描述在源代码中插入了事件处理程序的位置。

返回

Int32

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

注解

COM 签名

从 singlefileeditor:

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

此方法返回整个事件处理程序正文和一个字符串表示形式,它在给定的类上下文中唯一标识该事件成员。 如果事件处理程序已存在,则将返回该类成员的唯一成员 ID,其中包含事件正文和成员 ID 的空字符串。

itemidInsertionPoint参数指示设计器要在其中放置新方法的文件/缓冲区。 如果该方法不存在,则在参数中返回的插入点 pSpanInsertionPoint 适用于所请求的的缓冲区 itemid

请注意,此方法不会将生成的事件处理程序注入到次要缓冲区或分部类文件中,而只会插入主缓冲区。

适用于