/// <summary> /// Initializes a new instance of the <see cref="Config"/> class. /// </summary> /// <param name="configPath">The configuration path.</param> /// <param name="defaults">The defaults.</param> public Config(string configPath) { if (!string.IsNullOrEmpty(configPath)) { if (confParsed == null) { confParsed = new Dictionary <string, ParseConfig>(); } if (confMtime == null) { confMtime = new Dictionary <string, DateTime>(); } try { DateTime configWriteTime = (new FileInfo(configPath)).LastWriteTime; if ((!confParsed.ContainsKey(configPath)) || (configWriteTime != confMtime[configPath])) { confParsed[configPath] = new ParseConfig(configPath); confMtime[configPath] = configWriteTime; } config = confParsed[configPath]; } catch (IOException ioException) { throw ioException; } } }
/// <summary> /// Initializes a new instance of the <see cref="Config"/> class. /// </summary> /// <param name="configPath">The configuration path.</param> /// <param name="defaults">The defaults.</param> public Config(string configPath) { if (!string.IsNullOrEmpty(configPath)) { if (confParsed == null) { confParsed = new Dictionary<string, ParseConfig>(); } if (confMtime == null) { confMtime = new Dictionary<string, DateTime>(); } try { DateTime configWriteTime = (new FileInfo(configPath)).LastWriteTime; if ((!confParsed.ContainsKey(configPath)) || (configWriteTime != confMtime[configPath])) { confParsed[configPath] = new ParseConfig(configPath); confMtime[configPath] = configWriteTime; } config = confParsed[configPath]; } catch (IOException ioException) { throw ioException; } } }
public void Test_GetConfigKeys() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string[] keys = config.GetKeys(""); Assert.IsNotNull(keys.Select(k => k == "CONFIG_VALUE").Count() > 0); }
public void Test_GetDefaultConfigValueNoGroup() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string value = config.GetValue("not existant", "not existant", "Value"); Assert.AreEqual("Value", value); }
public void Test_GetSectionConfigValue() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string value = config.GetValue("CONFIG_VALUE", "Test Group"); Assert.AreEqual("testing", value); }
public void Test_GetConfigValue() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string value = config.GetValue("CLOUD_DOMAIN"); Assert.AreEqual("example.com", value); }
public void Test_LoadConfigFile() { ParseConfig config; try { config = new ParseConfig(TestHelper.GetNodeConfigPath()); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public void Test_GetConfigSectionsConfig() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string[] sections = config.GetSections(); Assert.IsNotNull(sections.Count() == 1); }
public void Test_GetCategoryConfigKeys() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string[] keys = config.GetKeys("Test Group"); Assert.IsNotNull(keys.Count() == 1); }
public void Test_AddKeyParserConfig() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string newFilePath = System.IO.Path.GetTempFileName(); config.WriteValue("NEWKEY", "NEWVALUE"); config.Save(newFilePath); ParseConfig newConfig = new ParseConfig(newFilePath); string value = newConfig.GetValue("NEWKEY"); Assert.AreEqual("NEWVALUE", value); File.Delete(newFilePath); }
public void Test_SaveParserConfigFile() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string newFilePath = System.IO.Path.GetTempFileName(); try { config.Save(newFilePath); } catch (Exception ex) { Assert.Fail(ex.ToString()); } finally { File.Delete(newFilePath); } }
public void Test_GetConfigComents() { ParseConfig config = new ParseConfig(TestHelper.GetNodeConfigPath()); string value = config.GetValue("MOTD_FILE"); Assert.AreEqual(value, ""); }