ExpansionProvider.OnBeforeInsertion Method (IVsExpansionSession)

 

Called just before the snippet has been inserted into the source.

Namespace:   Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)

public virtual int OnBeforeInsertion(
	IVsExpansionSession session
)

Parameters

session
Type: Microsoft.VisualStudio.TextManager.Interop.IVsExpansionSession

[in] An IVsExpansionSession object representing the expansion session that is currently active.

Return Value

Type: System.Int32

If successful, returns S_OK; otherwise, returns an error code.

This method provides an opportunity to set up default values for fields based on the snippet template to be inserted. If this method returns an error code, the snippet insertion is stopped.

This method is an implementation of the OnBeforeInsertion method on the IVsExpansionClient interface.

The base method sets the internal flag indicating an expansion session is active, caches the given IVsExpansionSession object, and then calls the SetFieldDefault method on the IVsExpansionSession object for each default field value in the internal default field values list. The base method always returns S_OK unless the session object is null in which case the base method returns E_UNEXPECTED (a valid session object must be given to this method).

Return to top
Show: