private bool TryGetTextManagerOptionValue(string valueName, ref int optionValue)
        {
            bool result = false;

            // Note: The CacheLanguageGuids method (used by LanguageGuids.Value) depends on
            // MainPackage.Instance, so we can't pull Value until the package instance is set.
            Guid langGuid;

            if (MainPackage.Instance != null && LanguageGuids.Value.TryGetValue(this.textManagerLanguageName, out langGuid))
            {
                IVsTextManager textManager = (IVsTextManager)MainPackage.GetGlobalService(typeof(SVsTextManager));
                if (textManager != null)
                {
                    LANGPREFERENCES[] langPrefs = new LANGPREFERENCES[1];
                    langPrefs[0].guidLang = langGuid;
                    int hr = textManager.GetUserPreferences(null, null, langPrefs, null);
                    if (ErrorHandler.Succeeded(hr))
                    {
                        switch (valueName)
                        {
                        case InsertTabsOptionName:
                            optionValue = unchecked ((int)langPrefs[0].fInsertTabs);
                            result      = true;
                            break;

                        case TabSizeOptionName:
                            optionValue = unchecked ((int)langPrefs[0].uTabSize);
                            result      = true;
                            break;
                        }
                    }
                }
            }

            return(result);
        }