Share via


MethodData.GetContextStream Method

Converts the current context span to a file position and length.

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.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)

Syntax

'Declaration
Public Function GetContextStream ( _
    <OutAttribute> ByRef pos As Integer, _
    <OutAttribute> ByRef length As Integer _
) As Integer
public int GetContextStream(
    out int pos,
    out int length
)
public:
virtual int GetContextStream(
    [OutAttribute] int% pos, 
    [OutAttribute] int% length
) sealed
abstract GetContextStream : 
        pos:int byref * 
        length:int byref -> int  
override GetContextStream : 
        pos:int byref * 
        length:int byref -> int
public final function GetContextStream(
    pos : int, 
    length : int
) : int

Parameters

  • pos
    Type: System.Int32%

    [out] Returns the position in the source file that corresponds to the start of the context span.

  • length
    Type: System.Int32%

    [out] Returns the length of the span.

Return Value

Type: System.Int32
If successful, returns S_OK; otherwise, returns an error code.

Implements

IVsMethodData.GetContextStream(Int32%, Int32%)

Remarks

This method converts the TextSpan object that was passed to the Refresh method into a file or stream position and length. The position in this case is a character offset from the beginning of the file.

The base method uses the GetNearestPosition method on the IVsTextView object (that was passed to the Refresh method) to convert the starting line/character offset and ending line/character offset to file positions and then returns the starting file position and the difference between the two positions as the length. This method throws a COMException exception if there were any errors and always returns a success code of S_OK.

This method is an implementation of the GetContextStream method on the IVsMethodData interface.

.NET Framework Security

See Also

Reference

MethodData Class

Microsoft.VisualStudio.Package Namespace