共用方式為


ExpansionProvider.InsertNamedExpansion Method

Inserts the specified snippet into the source at the given position.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)

Syntax

'宣告
Public Overridable Function InsertNamedExpansion ( _
    view As IVsTextView, _
    title As String, _
    path As String, _
    pos As TextSpan, _
    showDisambiguationUI As Boolean _
) As Boolean
'用途
Dim instance As ExpansionProvider
Dim view As IVsTextView
Dim title As String
Dim path As String
Dim pos As TextSpan
Dim showDisambiguationUI As Boolean
Dim returnValue As Boolean

returnValue = instance.InsertNamedExpansion(view, _
    title, path, pos, showDisambiguationUI)
public virtual bool InsertNamedExpansion(
    IVsTextView view,
    string title,
    string path,
    TextSpan pos,
    bool showDisambiguationUI
)
public:
virtual bool InsertNamedExpansion(
    IVsTextView^ view, 
    String^ title, 
    String^ path, 
    TextSpan pos, 
    bool showDisambiguationUI
)
abstract InsertNamedExpansion : 
        view:IVsTextView * 
        title:string * 
        path:string * 
        pos:TextSpan * 
        showDisambiguationUI:bool -> bool 
override InsertNamedExpansion : 
        view:IVsTextView * 
        title:string * 
        path:string * 
        pos:TextSpan * 
        showDisambiguationUI:bool -> bool 
public function InsertNamedExpansion(
    view : IVsTextView, 
    title : String, 
    path : String, 
    pos : TextSpan, 
    showDisambiguationUI : boolean
) : boolean

Parameters

  • title
    Type: System.String
    [in] A string containing the name or title of the snippet.
  • path
    Type: System.String
    [in] A string containing the path to the snippet template file.
  • showDisambiguationUI
    Type: System.Boolean
    [in] This is true if there is more than one snippet with the given title and a dialog box must be shown so the user can select which snippet to insert; otherwise, this is false (accept the first snippet with the given title).

Return Value

Type: System.Boolean
If a snippet was inserted, returns true; otherwise, returns false.

Remarks

This is a helper method that can be called from your own code, typically in association with the FindExpansionByShortcut method. See the example in the ViewFilter class to see how this method is used.

The base method calls the InsertNamedExpansion method on the IVsExpansion object. If InsertNamedExpansion succeeds, the ExpansionProvider class is put into the edit expansion mode and the base method returns true. Otherwise, the edit session is ended and the base method returns false.

.NET Framework Security

See Also

Reference

ExpansionProvider Class

ExpansionProvider Members

Microsoft.VisualStudio.Package Namespace