コード例 #1
0
ファイル: LanguagePreferences.cs プロジェクト: int19h/PTVS
        public LanguagePreferences(IServiceProvider site, Guid languageGuid)
        {
            site.AssertShellIsInitialized();

            _textMgr = (IVsTextManager)site.GetService(typeof(SVsTextManager));
            if (_textMgr == null)
            {
                throw new NotSupportedException("");
            }

            var langPrefs = new LANGPREFERENCES[1];

            langPrefs[0].guidLang = languageGuid;
            ErrorHandler.ThrowOnFailure(_textMgr.GetUserPreferences(null, null, langPrefs, null));
            _preferences = langPrefs[0];

            var guid = typeof(IVsTextManagerEvents2).GUID;
            IConnectionPoint connectionPoint = null;

            (_textMgr as IConnectionPointContainer)?.FindConnectionPoint(ref guid, out connectionPoint);
            if (connectionPoint != null)
            {
                connectionPoint.Advise(this, out _cookie);
            }
        }