Condividi tramite


LanguageService.GetLanguagePreferences Method

Returns a LanguagePreferences object for this language service.

Namespace:  Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

Syntax

Public MustOverride Function GetLanguagePreferences As LanguagePreferences

Dim instance As LanguageService
Dim returnValue As LanguagePreferences

returnValue = instance.GetLanguagePreferences()
public abstract LanguagePreferences GetLanguagePreferences()
public:
virtual LanguagePreferences^ GetLanguagePreferences() abstract
public abstract function GetLanguagePreferences() : LanguagePreferences

Return Value

Type: Microsoft.VisualStudio.Package.LanguagePreferences

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

Remarks

This method must be implemented in a class derived from LanguageService. It is expected that you will have a single preferences object shared with all instances of your language service. If you do not need any custom preferences beyond those supplied by the LanguagePreferences class, you can just return an instance of the LanguagePreferences class.

Examples

This example shows an implementation of this method. Note how the matching braces option is temporarily enabled here (typically, this is set using the ProvideLanguageServiceAttribute user attribute when the language service is installed but for debugging purposes, it is often convenient to set or clear the various preference flags temporarily).

using Microsoft.VisualStudio.Package;

namespace MyLanguagePackage
{
    private LanguagePreferences preferences;

    public class MyLanguageService : LanguageService
    {
        if (this.preferences == null)
        {
            this.preferences = new LanguagePreferences(this.Site,
                                                        typeof(MyLanguageService).GUID,
                                                        this.Name);
            if (this.preferences != null)
            {
                this.preferences.Init();  // Must do this first!

                // Temporarily enable the following properties.
                this.preferences.EnableMatchBraces = true;
            }
        }
        return this.preferences;
    }
}

Permissions

See Also

Reference

LanguageService Class

LanguageService Members

Microsoft.VisualStudio.Package Namespace