Partager via


IVsExpansion.InsertNamedExpansion Method

Inserts snippet with the specified name at the specified 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

'Déclaration
Function InsertNamedExpansion ( _
    bstrTitle As String, _
    bstrPath As String, _
    tsInsertPos As TextSpan, _
    pExpansionClient As IVsExpansionClient, _
    guidLang As Guid, _
    fShowDisambiguationUI As Integer, _
    <OutAttribute> ByRef pSession As IVsExpansionSession _
) As Integer
int InsertNamedExpansion(
    string bstrTitle,
    string bstrPath,
    TextSpan tsInsertPos,
    IVsExpansionClient pExpansionClient,
    Guid guidLang,
    int fShowDisambiguationUI,
    out IVsExpansionSession pSession
)
int InsertNamedExpansion(
    [InAttribute] String^ bstrTitle, 
    [InAttribute] String^ bstrPath, 
    [InAttribute] TextSpan tsInsertPos, 
    [InAttribute] IVsExpansionClient^ pExpansionClient, 
    [InAttribute] Guid guidLang, 
    [InAttribute] int fShowDisambiguationUI, 
    [OutAttribute] IVsExpansionSession^% pSession
)
abstract InsertNamedExpansion : 
        bstrTitle:string * 
        bstrPath:string * 
        tsInsertPos:TextSpan * 
        pExpansionClient:IVsExpansionClient * 
        guidLang:Guid * 
        fShowDisambiguationUI:int * 
        pSession:IVsExpansionSession byref -> int 
function InsertNamedExpansion(
    bstrTitle : String, 
    bstrPath : String, 
    tsInsertPos : TextSpan, 
    pExpansionClient : IVsExpansionClient, 
    guidLang : Guid, 
    fShowDisambiguationUI : int, 
    pSession : IVsExpansionSession
) : int

Parameters

  • bstrTitle
    Type: System.String
    [in] The full name of the code snippet.
  • bstrPath
    Type: System.String
    [inThe full path to the code snippet file.
  • guidLang
    Type: System.Guid
    [in] The GUID of the language service. Can be nulla null reference (Nothing in Visual Basic). The default is the language service of the file.
  • fShowDisambiguationUI
    Type: System.Int32
    [in] This is non-zero (true) if a "disambiguation user interface (UI)" can be shown in the case where multiple snippets with the same name are found. If this value is zero (false) then the first snippet that matches the name is inserted.

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::InsertNamedExpansion(
   [in]BSTR bstrTitle,
   [in] BSTR bstrPath,
   [in] TextSpan tsInsertPos,
   [in]IVsExpansionClient *pExpansionClient,
   [in]GUID guidLang,
   [in] bool fShowDisambiguationUI,
   [out] IVsExpansionSession **pSession
);

This method used to insert a code snippet when the name and path of the code snippet is known. The name and path can be obtained from the code snippet's shortcut by calling the M:Microsoft.VisualStudio.TextManager.Interop.IVsExpansionManager.GetExpansionByShortcut(Microsoft.VisualStudio.TextManager.Interop.IVsExpansionClient,System.Guid,System.String,Microsoft.VisualStudio.TextManager.Interop.IVsTextView,Microsoft.VisualStudio.TextManager.Interop.TextSpan[],System.Int32,System.String@,System.String@) method in the IVsExpansionManager interface.

This method is typically called from an implementation of the OnItemChosen method in the IVsExpansionClient interface as the OnItemChosen method is given the name and path of the code snippet.

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

See Also

Reference

IVsExpansion Interface

Microsoft.VisualStudio.TextManager.Interop Namespace