IVsExpansion::InsertSpecificExpansion Method (IXMLDOMNode^, TextSpan, IVsExpansionClient^, Guid, String^, IVsExpansionSession^)

 

Inserts the code snippet from the specified XML node into the text buffer at the specified position.

Namespace:   Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)

int InsertSpecificExpansion(
	IXMLDOMNode^ pSnippet,
	TextSpan tsInsertPos,
	IVsExpansionClient^ pExpansionClient,
	Guid guidLang,
	String^ pszRelativePath,
	[OutAttribute] IVsExpansionSession^% pSession
)

Parameters

pSnippet
Type: MSXML::IXMLDOMNode^

[in] Contains the code snippet text.

tsInsertPos
Type: Microsoft.VisualStudio.TextManager.Interop::TextSpan

[in] The location in the text buffer to insert the code snippet.

pExpansionClient
Type: Microsoft.VisualStudio.TextManager.Interop::IVsExpansionClient^

[in] Receives notifications about the insertion process. This can be null.

guidLang
Type: System::Guid

[in] The GUID of the language service. Can be null. The default is the language service of the file.

pszRelativePath
Type: System::String^

[in] A path that is used if the node references an external file. This is typically null.

pSession
Type: Microsoft.VisualStudio.TextManager.Interop::IVsExpansionSession^

[out] The session 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.

From textmgr2.idl:

HRESULT IVsExpansion::InsertSpecificExpansion(
   [in]IXMLDOMNode *pSnippet,
   [in] TextSpan tsInsertPos,
   [in]IVsExpansionClient *pExpansionClient,
   [in]GUID guidLang,
   [in] BSTR pszRelativePath,
   [out] IVsExpansionSession **pSession
);

This method is used only if you are working directly with code snippet files and is rarely used.

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 (M:Microsoft.VisualStudio.TextManager.Interop.IVsExpansionClient.IsValidKind(Microsoft.VisualStudio.TextManager.Interop.IVsTextLines,Microsoft.VisualStudio.TextManager.Interop.TextSpan[],System.String) method) to make sure the snippet can actually be inserted at the specified location.

Return to top
Show: