Sdílet prostřednictvím


LanguageService.CreateViewFilter(CodeWindowManager, IVsTextView) Method

Definition

Instantiates a ViewFilter class.

public:
 virtual Microsoft::VisualStudio::Package::ViewFilter ^ CreateViewFilter(Microsoft::VisualStudio::Package::CodeWindowManager ^ mgr, Microsoft::VisualStudio::TextManager::Interop::IVsTextView ^ newView);
public virtual Microsoft.VisualStudio.Package.ViewFilter CreateViewFilter (Microsoft.VisualStudio.Package.CodeWindowManager mgr, Microsoft.VisualStudio.TextManager.Interop.IVsTextView newView);
abstract member CreateViewFilter : Microsoft.VisualStudio.Package.CodeWindowManager * Microsoft.VisualStudio.TextManager.Interop.IVsTextView -> Microsoft.VisualStudio.Package.ViewFilter
override this.CreateViewFilter : Microsoft.VisualStudio.Package.CodeWindowManager * Microsoft.VisualStudio.TextManager.Interop.IVsTextView -> Microsoft.VisualStudio.Package.ViewFilter
Public Overridable Function CreateViewFilter (mgr As CodeWindowManager, newView As IVsTextView) As ViewFilter

Parameters

mgr
CodeWindowManager

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

newView
IVsTextView

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

Returns

If successful, returns a ViewFilter object; otherwise, returns a null value.

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

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.

Applies to