Freigeben über


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
)

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