Partager via


LanguageService.CreateViewFilter Method

Instantiates a ViewFilter class.

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

Syntax

'Declaration
Public Overridable Function CreateViewFilter ( _
    mgr As CodeWindowManager, _
    newView As IVsTextView _
) As ViewFilter
public virtual ViewFilter CreateViewFilter(
    CodeWindowManager mgr,
    IVsTextView newView
)
public:
virtual ViewFilter^ CreateViewFilter(
    CodeWindowManager^ mgr, 
    IVsTextView^ newView
)
abstract CreateViewFilter : 
        mgr:CodeWindowManager * 
        newView:IVsTextView -> ViewFilter  
override CreateViewFilter : 
        mgr:CodeWindowManager * 
        newView:IVsTextView -> ViewFilter
public function CreateViewFilter(
    mgr : CodeWindowManager, 
    newView : IVsTextView
) : ViewFilter

Parameters

Return Value

Type: Microsoft.VisualStudio.Package.ViewFilter
If successful, returns a ViewFilter object; otherwise, returns a null value.

Remarks

A view filter provides handling for various commands the user can issue in Visual Studio. If your language service supports commands other than those supported by the default ViewFilter, you must derive a class from the ViewFilter class and return a new instance of your class from this method. See ViewFilter for details on supported commands.

The base method always returns a new ViewFilter object. This is typically called when the CodeWindowManager attaches to a new text view.

Examples

Here is an example implementation of this method. Note the call to the GetIVsDebugger method. The first time the GetIVsDebugger method is called, it hooks up the view to watch for debugger events. Without this call, your view does not receive any debugger events.

using Microsoft.VisualStudio.Package;

namespace MyLanguagePackage
{
    public class MyLanguageService : LanguageService
    {
        public override ViewFilter CreateViewFilter(CodeWindowManager mgr,
                                                    IVsTextView newView)
        {
            // This call makes sure debugging events can be received
            // by our view filter.
            base.GetIVsDebugger();
            return new MyViewFilter(mgr, newView);
        }
    }
}

.NET Framework Security

See Also

Reference

LanguageService Class

Microsoft.VisualStudio.Package Namespace