Udostępnij za pośrednictwem


LanguageService.GetLanguagePreferences Method

Definition

Returns a LanguagePreferences object for this language service.

public:
 abstract Microsoft::VisualStudio::Package::LanguagePreferences ^ GetLanguagePreferences();
public abstract Microsoft.VisualStudio.Package.LanguagePreferences GetLanguagePreferences ();
abstract member GetLanguagePreferences : unit -> Microsoft.VisualStudio.Package.LanguagePreferences
Public MustOverride Function GetLanguagePreferences () As LanguagePreferences

Returns

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

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 MyLanguage  
{  
    class MyLanguageService : LanguageService  
    {  
        private LanguagePreferences preferences;  

        public override LanguagePreferences GetLanguagePreferences()  
        {  
            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;  

        }   
    }  
}  

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.

Applies to