public void SetOptionAndUpdatePreview <T>(T value, IOption option, string preview)
        {
            if (option is Option <CodeStyleOption <T> > )
            {
                var opt = OptionStore.GetOption((Option <CodeStyleOption <T> >)option);
                opt.Value = value;
                OptionStore.SetOption((Option <CodeStyleOption <T> >)option, opt);
            }
            else if (option is PerLanguageOption <CodeStyleOption <T> > )
            {
                var opt = OptionStore.GetOption((PerLanguageOption <CodeStyleOption <T> >)option, Language);
                opt.Value = value;
                OptionStore.SetOption((PerLanguageOption <CodeStyleOption <T> >)option, Language, opt);
            }
            else if (option is Option <T> )
            {
                OptionStore.SetOption((Option <T>)option, value);
            }
            else if (option is PerLanguageOption <T> )
            {
                OptionStore.SetOption((PerLanguageOption <T>)option, Language, value);
            }
            else
            {
                throw new InvalidOperationException("Unexpected option type");
            }

            UpdateDocument(preview);
        }
        public void SetOptionAndUpdatePreview <T>(T value, IOption option, string preview)
        {
            var key = new OptionKey(option, option.IsPerLanguage ? Language : null);

            if (option.DefaultValue is ICodeStyleOption codeStyleOption)
            {
                // The value provided is either an ICodeStyleOption OR the underlying ICodeStyleOption.Value
                if (value is ICodeStyleOption newCodeStyleOption)
                {
                    OptionStore.SetOption(
                        key,
                        codeStyleOption
                        .WithValue(newCodeStyleOption.Value)
                        .WithNotification(newCodeStyleOption.Notification)
                        );
                }
                else
                {
                    OptionStore.SetOption(key, codeStyleOption.WithValue(value));
                }
            }
            else
            {
                OptionStore.SetOption(key, value);
            }

            UpdateDocument(preview);
        }
        public void SetOptionAndUpdatePreview <T>(T value, IOption option, string preview)
        {
            var key = new OptionKey(option, option.IsPerLanguage ? Language : null);

            if (option.DefaultValue is ICodeStyleOption codeStyleOption)
            {
                OptionStore.SetOption(key, codeStyleOption.WithValue(value));
            }
            else
            {
                OptionStore.SetOption(key, value);
            }

            UpdateDocument(preview);
        }