LanguageService.GetLanguagePreferences Method

Returns a LanguagePreferences object for this language service.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

Syntax

'Declaration
Public MustOverride Function GetLanguagePreferences As LanguagePreferences
public abstract LanguagePreferences GetLanguagePreferences()
public:
virtual LanguagePreferences^ GetLanguagePreferences() abstract
abstract GetLanguagePreferences : unit -> LanguagePreferences
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;
    }
}

.NET Framework Security

See Also

Reference

LanguageService Class

Microsoft.VisualStudio.Package Namespace