コード例 #1
0
ファイル: Program.cs プロジェクト: quemitariousa/ITMO-OOP
        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")}");
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }