Compartilhar via


Source.GetUserData Method

Gets the user data associated with the specified GUID.

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

Syntax

'Declaration
Public Function GetUserData ( _
    ByRef key As Guid _
) As Object
public Object GetUserData(
    ref Guid key
)
public:
Object^ GetUserData(
    Guid% key
)
member GetUserData : 
        key:Guid byref -> Object
public function GetUserData(
    key : Guid
) : Object

Parameters

  • key
    Type: Guid%

    The GUID specifying what user data to retrieve.

Return Value

Type: Object
If successful, returns an object representing the requested data; otherwise, returns an error code.

Remarks

This method obtains the IVsUserData interface from the IVsTextLines object (which was passed to the Source class constructor), and then calls the GetData method with the given GUID.

The following GUIDs are supported:

GUID

Value Type

Description

GUID_VsLang_Support_CF_HTML

Boolean

True if the language service recognizes the clipboard format CF_HTML and allows pasting of HTML fragments.

Examples

Here is an example of how to call this method (see "Language GUIDs" section of the IDE GUIDs topics to get the value for the GUID_VsLang_Support_CF_HTML constant).

namespace MyLanguagePackage
{
    class MySource : Source
    {
        bool IsHTMLSupported()
        {
            bool bSupported = false;
            object value = GetUserData(GUID_VSLang_Support_CF_HTML);
            if (value != null)
            {
                bSupported = Convert.ToBoolean(value);
            }
            return bSupported;
        }
    }
}

.NET Framework Security

See Also

Reference

Source Class

Microsoft.VisualStudio.Package Namespace