次の方法で共有


LanguagePreferences.OnRegisterMarkerType Method

Called when a new marker type is registered with Visual Studio.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.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

'宣言
Public Overridable Function OnRegisterMarkerType ( _
    iMarkerType As Integer _
) As Integer
'使用
Dim instance As LanguagePreferences
Dim iMarkerType As Integer
Dim returnValue As Integer

returnValue = instance.OnRegisterMarkerType(iMarkerType)
public virtual int OnRegisterMarkerType(
    int iMarkerType
)
public:
virtual int OnRegisterMarkerType(
    int iMarkerType
)
abstract OnRegisterMarkerType : 
        iMarkerType:int -> int 
override OnRegisterMarkerType : 
        iMarkerType:int -> int 
public function OnRegisterMarkerType(
    iMarkerType : int
) : int

Parameters

  • iMarkerType
    Type: System.Int32
    [in] The ID of the marker type.

Return Value

Type: System.Int32

Implements

IVsTextManagerEvents2.OnRegisterMarkerType(Int32)

Remarks

This method is called whenever a new marker type is registered. Call the GetMarkerTypeInterface method with the specified marker ID to obtain an IVsTextMarkerType object that can be queried for details on the new marker type. A language service typically does not need to implement this method.

This method is an implementation of IVsTextManagerEvents2.OnRegisterMarkerType.

The base method does nothing.

Examples

Here is an example of how to obtain the IVsTextManager2 interface and get the marker type.

using Microsoft.VisualStudio.Package;

namespace MyLanguagePackage
{
    class MyLanguagePreferences : LanguagePreferences
    {
        override public void OnRegisterMarkerType(int iMarkerType)
        {
            IVsTextManager2 pTextManager;
            pTextManager = Site.GetService(typeof(SVsTextManager)) as IVsTextManager2;
            if (pTextManager != null)
            {
                IVsTextMarkerType pMarkerType;
                pTextManager.GetMarkerTypeInterface(iMarkerType,out pMarkerType);
                if (pMarkerType != null)
                {
                    // Examine marker type here.
                }
            }
        }
    }
}

.NET Framework Security

See Also

Reference

LanguagePreferences Class

LanguagePreferences Members

Microsoft.VisualStudio.Package Namespace