Export (0) Print
Expand All
Expand Minimize

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)

public virtual ViewFilter CreateViewFilter(
	CodeWindowManager mgr,
	IVsTextView newView
)

Parameters

mgr
Type: Microsoft.VisualStudio.Package.CodeWindowManager

[in] The CodeWindowManager object to associate with this view filter.

newView
Type: Microsoft.VisualStudio.TextManager.Interop.IVsTextView

[in] The IVsTextView object that is to receive the new view filter.

Return Value

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

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.

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);
        }
    }
}

Show:
© 2015 Microsoft