static void Main(string[] args) { string theFile = "file.txt"; IniParser iniParser = new IniParser(); IniData iniFile = iniParser.Parse(theFile); Console.WriteLine($"[COMMON] DiskCachePath = {iniFile.GetString("COMMON", "DiskCachePath")}"); Console.WriteLine($"[COMMON] LogXML = {iniFile.GetInt("COMMON", "LogXML")}"); Console.WriteLine($"[ADC_DEV] BufferLenSecons = {iniFile.GetFloat("ADC_DEV", "BufferLenSecons")}"); }
public void ParseWithComments() { string fileName = "test.txt"; string text = "[A]\n B=C ;poebota"; File.WriteAllText(fileName, text); IniParser parser = new IniParser(); IniData iniData = parser.Parse(fileName); string supposedResult = "C"; string result = iniData.GetString("A", "B"); Assert.AreEqual(result, supposedResult); }
public void ReadFloatProperty() { string fileName = "test.txt"; string text = "[A]\n B=0.5"; File.WriteAllText(fileName, text); IniParser parser = new IniParser(); IniData iniData = parser.Parse(fileName); string supposedResult = "0.5"; string result = iniData.GetString("A", "B"); Assert.AreEqual(result, supposedResult); }
public void ReadStringProperty() { // Arrange string fileName = "test.txt"; string text = "[A]\n B=C"; File.WriteAllText(fileName, text); IniParser parser = new IniParser(); IniData iniData = parser.Parse(fileName); string supposedResult = "C"; // Act string result = iniData.GetString("A", "B"); // Assert Assert.AreEqual(result, supposedResult); }