private void ImportOptionsButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog()
            {
                Filter          = "All Files  (*.*)|*.*",
                CheckPathExists = true,
                Multiselect     = false,
            };

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            EditorConfigCodeAnalysisConfig config = EditorConfigCodeAnalysisConfigLoader.LoadAndCatchIfThrows(new string[] { dialog.FileName }, ex => ShowErrorMessage(ex));

            VSPackage package = VSPackage.Instance;

            package.RefactoringsOptionsPage.Load();
            package.CodeFixesOptionsPage.Load();

            Update(package.RefactoringsOptionsPage, config.GetRefactorings());
            Update(package.CodeFixesOptionsPage, config.GetCodeFixes());
        private void ExportOptionsButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new SaveFileDialog()
            {
                Filter          = "All Files  (*.*)|*.*",
                FileName        = Path.GetFileName(EditorConfigCodeAnalysisConfig.FileName),
                DefaultExt      = "editorconfig",
                AddExtension    = true,
                CheckPathExists = true,
                OverwritePrompt = true,
            };

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            VSPackage package = VSPackage.Instance;

            IEnumerable <KeyValuePair <string, bool> > refactorings = null;

            if (package.RefactoringsOptionsPage.IsLoaded)
            {
                refactorings = package.RefactoringsOptionsPage
                               .Control
                               .Items
                               .Where(f => f.Enabled.HasValue)
                               .Select(f => new KeyValuePair <string, bool>(f.Id, f.Enabled.Value));
            }
            else
            {
                refactorings = package.RefactoringsOptionsPage.GetItems();
            }

            IEnumerable <KeyValuePair <string, bool> > codeFixes = null;

            if (package.CodeFixesOptionsPage.IsLoaded)
            {
                codeFixes = package.CodeFixesOptionsPage
                            .Control
                            .Items
                            .Where(f => f.Enabled.HasValue)
                            .Select(f => new KeyValuePair <string, bool>(f.Id, f.Enabled.Value));
            }
            else
            {
                codeFixes = package.CodeFixesOptionsPage.GetItems();
            }

            var options = new Dictionary <string, string>();

            try
            {
                EditorConfigCodeAnalysisConfig.Save(
                    dialog.FileName,
                    options: options,
                    refactorings: refactorings,
                    codeFixes: codeFixes);
            }
            catch (Exception ex) when(ex is IOException ||
                                      ex is UnauthorizedAccessException)
            {
                ShowErrorMessage(ex);
            }
        }