private static IAppSettings loadSettings(string file)
        {
            var loader = new SettingsLoader();

            loader.XmlFileBySection();
            loader.JsonFileBySection();
            loader.IniFileBySection();

            loader.Loaded += (s, e) =>
            {
                Console.WriteLine("Loaded: {0} ({1})", e.Settings.GetType(), e.Settings.Identity);
            };

            if (Path.GetExtension(file) == ".xml")
            {
                return(loader.LoadSettings(new XmlFileSettings(Path.Combine("Including".ResolveTestPath(), file))).Joined.ToAppSettings());
            }
            else
            {
                return(loader.LoadSettings(new JsonFileSettings(Path.Combine("Including".ResolveTestPath(), file))).Joined.ToAppSettings());
            }
        }
Esempio n. 2
0
        public void LoadJson()
        {
            var loader = new SettingsLoader();

            loader.XmlFileBySection();
            loader.JsonFileBySection();
            loader.JsonFileByExtension();

            loader.Loaded += (s, e) =>
            {
                Console.WriteLine("Loaded: {0} ({1})", e.Settings.GetType(), e.Settings.Identity);
            };

            var settings = loader
                           .LoadSettings(new XmlFileSettings("Examples/AppDirectory/mainJson.config".ResolveTestPath()))
                           .Joined
                           .ToAppSettings();

            var addCfg = settings.TryGet <ExampleCombineConfig>("AdditionalConfig");

            Assert.IsNotNull(addCfg);
            Assert.AreEqual("InAppDirectory_json", addCfg.F);
        }