Example #1
0
        public void TestConfig(JObject json)
        {
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            _profilePath = Path.Combine(path, "Profiles");

            if (File.Exists(Path.Combine(_profilePath, "settings.json")))
            {
                File.Delete(Path.Combine(_profilePath, "settings.json"));
            }

            IEnumerable <Type> allSettingProvider = Assembly.GetAssembly(typeof(Engine)).GetTypes()
                                                    .Where(t => typeof(ISettingProvider).IsAssignableFrom(t) && t.IsClass);

            Options options = new Options();

            foreach (Type type in allSettingProvider)
            {
                if (!type.IsPublic)
                {
                    continue;
                }

                ISettingProvider p = (ISettingProvider)Activator.CreateInstance(type);

                p.Deserialize(json, options);

                p.Serialize(json);
            }

            if (File.Exists(Path.Combine(_profilePath, "settings.json")))
            {
                File.Delete(Path.Combine(_profilePath, "settings.json"));
            }
        }