IVsExpansion.InsertExpansion Method
Inserts the code snippet associated with the shortcut that can be found at the given context position in the text buffer.
Namespace: Microsoft.VisualStudio.TextManager.Interop
Assembly: Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)
Syntax
'Declaration
Function InsertExpansion ( _
tsContext As TextSpan, _
tsInsertPos As TextSpan, _
pExpansionClient As IVsExpansionClient, _
guidLang As Guid, _
<OutAttribute> ByRef pSession As IVsExpansionSession _
) As Integer
int InsertExpansion(
TextSpan tsContext,
TextSpan tsInsertPos,
IVsExpansionClient pExpansionClient,
Guid guidLang,
out IVsExpansionSession pSession
)
int InsertExpansion(
[InAttribute] TextSpan tsContext,
[InAttribute] TextSpan tsInsertPos,
[InAttribute] IVsExpansionClient^ pExpansionClient,
[InAttribute] Guid guidLang,
[OutAttribute] IVsExpansionSession^% pSession
)
abstract InsertExpansion :
tsContext:TextSpan *
tsInsertPos:TextSpan *
pExpansionClient:IVsExpansionClient *
guidLang:Guid *
pSession:IVsExpansionSession byref -> int
function InsertExpansion(
tsContext : TextSpan,
tsInsertPos : TextSpan,
pExpansionClient : IVsExpansionClient,
guidLang : Guid,
pSession : IVsExpansionSession
) : int
Parameters
tsContext
Type: Microsoft.VisualStudio.TextManager.Interop.TextSpan[in] The span (a pair of beginning and ending positions) in the text buffer that contains the snippet shortcut.
tsInsertPos
Type: Microsoft.VisualStudio.TextManager.Interop.TextSpan[in] The span that is to be replaced by the snippet (typically includes the shortcut span).
pExpansionClient
Type: Microsoft.VisualStudio.TextManager.Interop.IVsExpansionClient[in] Teceives notifications about the insertion process. This can be a nulla null reference (Nothing in Visual Basic) value.
guidLang
Type: System.Guid[in] GUID of the language service. Can be a nulla null reference (Nothing in Visual Basic) value. Default is the language service of the file.
pSession
Type: Microsoft.VisualStudio.TextManager.Interop.IVsExpansionSession%[out] Returns an IVsExpansionSession object that is used while the snippet is being edited in place.
Return Value
Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
Remarks
COM Signature
From textmgr2.idl:
HRESULT IVsExpansion::InsertExpansion(
[in] TextSpan tsContext,
[in] TextSpan tsInsertPos,
[in]IVsExpansionClient *pExpansionClient,
[in]GUID guidLang,
[out] IVsExpansionSession **pSession
);
This method reads the snippet shortcut from the text buffer at the position specified by the tsContext parameter (remember, the IVsExpansion interface is implemented on the same object that implements the IVsTextBuffer interface), loads the snippet based on the shortcut and then inserts the snippet into the text buffer at position specified by the tsInsertPos parameter.
If an IVsExpansionClient object is supplied, it receives before (OnBeforeInsertion method) and after (OnAfterInsertion method) notifications during the insertion process. The expansion client is also used to validate the kind of snippet (IsValidKind method) to make sure the snippet can actually be inserted at the specified location.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.