<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Dynamic;
using System.IO;
using System.Linq;
using Caliburn.Micro;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace SuperbEdit.Base
{
    [Export(typeof (IConfig))]
    internal class Config : PropertyChangedBase, IConfig, IDisposable
    {
        private readonly FileSystemWatcher _defaultConfigWatcher;
        private readonly FileSystemWatcher _userConfigWatcher;
        private dynamic _defaultConfigExpandoObject;

        private dynamic _userConfigExpandoObject;

        [ImportingConstructor]
        public Config()
        {
            ReloadConfig(false, Path.Combine(Folders.UserFolder, "config.json"));
            ReloadConfig(true, Path.Combine(Folders.ProgramFolder, "config.json"));

            _defaultConfigWatcher = new FileSystemWatcher(Folders.ProgramFolder) {Filter = "config.json"};
            _userConfigWatcher = new FileSystemWatcher(Folders.UserFolder) {Filter = "config.json"};

            _defaultConfigWatcher.EnableRaisingEvents = true;
            _userConfigWatcher.EnableRaisingEvents = true;

            _defaultConfigWatcher.Changed += DefaultConfigChanged;
            _userConfigWatcher.Changed += UserConfigChanged;
        }

        public dynamic UserConfig
        {
            get { return _userConfigExpandoObject; }
            private set
            {
                if (_userConfigExpandoObject != value)
                {
                    _userConfigExpandoObject = value;
                    NotifyOfPropertyChange(() => UserConfig);
                }
            }
        }

        public dynamic DefaultConfig
        {
            get { return _defaultConfigExpandoObject; }
            private set
            {
                if (_defaultConfigExpandoObject != value)<commit_msg>Cherry picked commits with config edits form feature/test-suite.<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Dynamic;
using System.IO;
using System.Linq;
using Caliburn.Micro;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace SuperbEdit.Base
{
    [Export(typeof (IConfig))]
    internal class Config : PropertyChangedBase, IConfig, IDisposable
    {
        private readonly FileSystemWatcher _defaultConfigWatcher;
        private readonly FileSystemWatcher _userConfigWatcher;
        private dynamic _defaultConfigExpandoObject;

        private dynamic _userConfigExpandoObject;

        //Used only for test
        internal Config(string defaultConfig, string userConfig)
        {
            ReloadConfig(false, userConfig);
            ReloadConfig(true, defaultConfig);

            _defaultConfigWatcher = new FileSystemWatcher(Path.GetDirectoryName(defaultConfig)) {Filter = "config.json"};
            _userConfigWatcher = new FileSystemWatcher(Path.GetDirectoryName(userConfig)) {Filter = "config.json"};

            _defaultConfigWatcher.EnableRaisingEvents = true;
            _userConfigWatcher.EnableRaisingEvents = true;

            _defaultConfigWatcher.Changed += DefaultConfigChanged;
            _userConfigWatcher.Changed += UserConfigChanged;
        }

        [ImportingConstructor]
        public Config()
            : this(Path.Combine(Folders.ProgramFolder, "config.json"),
                Path.Combine(Folders.UserFolder, "config.json"))
        {
            
        }

        public dynamic UserConfig
        {
            get { return _userConfigExpandoObject; }
            private set
            {
                if (_userConfigExpandoObject != value)
                {
                    _userConfigExpandoObject = value;
                    NotifyOfPropertyChange(() => UserConfig);
                }
            }
        }

        public dynamic DefaultConfig
        {
            get { return _defaultConfigExpandoObject; }
            private set
            {
                if (_defaultConfigExpandoObject != value)
{'fraction_non_alphanumeric': 0.07204539847026893, 'fraction_numerical': 0.0, 'mean_word_length': 2.336625514403292, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3710665', 'n_tokens_mistral': 1029, 'n_tokens_neox': 986, 'n_words': 207}