IVsContainedLanguageCodeSupport::EnsureEventHandler Method (String^, String^, String^, String^, UInt32, String^, String^, array<TextSpan>^)
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.
Assembly: Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)
int EnsureEventHandler( String^ pszClassName, String^ pszObjectTypeName, String^ pszNameOfEvent, String^ pszEventHandlerName, unsigned int itemidInsertionPoint, [OutAttribute] String^% pbstrUniqueMemberID, [OutAttribute] String^% pbstrEventBody, array<TextSpan>^ pSpanInsertionPoint )
Parameters
- pszClassName
-
Type:
System::String^
[in] Name of the class.
- pszObjectTypeName
-
Type:
System::String^
[in] Name of the object.
- pszNameOfEvent
-
Type:
System::String^
[in] Name of the event.
- pszEventHandlerName
-
Type:
System::String^
[in] Name of the event handler.
- itemidInsertionPoint
-
Type:
System::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
-
Type:
System::String^
[out] Returns a unique member ID for the event handler.
- pbstrEventBody
-
Type:
System::String^
[out] Returns the returned event handler body.
- pSpanInsertionPoint
-
Type:
array<Microsoft.VisualStudio.TextManager.Interop::TextSpan>^
[out] Returns a TextSpan object describing the location in the source code where the event handler was inserted.
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.