Udostępnij za pośrednictwem


IVsContainedLanguageCodeSupport.EnsureEventHandler Method

Definition

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.

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

Parameters

pszClassName
String

[in] Name of the class.

pszObjectTypeName
String

[in] Name of the object.

pszNameOfEvent
String

[in] Name of the event.

pszEventHandlerName
String

[in] Name of the event handler.

itemidInsertionPoint
UInt32

[in] The file or buffer where the designer would like to put a new method. This is a unique identifier or it can be one of the following values: VSITEMID_NIL, VSITEMID_ROOT or VSITEMID_SELECTION.

pbstrUniqueMemberID
String

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

pbstrEventBody
String

[out] Returns the returned event handler body.

pSpanInsertionPoint
TextSpan[]

[out] Returns a TextSpan object describing the location in the source code where the event handler was inserted.

Returns

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.

Applies to