Ejemplo n.º 1
0
        private static void AddNewFormat()
        {
            string format = IO.ReadLine("Enter a format: ", removeWhiteSpace: false); // [[5]]

            if (AddNewFormat(format))
            {
                IO.WriteLineSuccess("Format added successfully.");
            }
        }
Ejemplo n.º 2
0
        private static void RemoveFormat()
        {
            string input = IO.ReadLine("Id of format to remove: ");
            int    id;

            if (!int.TryParse(input, out id))
            {
                IO.WriteLineError("You must enter a number!");
                return;
            }

            int removed = _formats.RemoveWhere(x => x.Index == id); //[[12]]

            if (removed == 0)
            {
                IO.WriteLineError("No formats with the specified ID found!");
            }
            else
            {
                IO.WriteLineSuccess("Format removed successfully.");
            }
        }
Ejemplo n.º 3
0
        private static void LoadFormatsFromFile()
        {
            string fileName;

            while (!GetInputFile(out fileName))
            {
                ;
            }
            if (!File.Exists(fileName))
            {
                IO.WriteLineError("The specified file could not be found.");
                return;
            }
            string[] lines = File.ReadAllLines(fileName).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();

            foreach (string line in lines)
            {
                if (!AddNewFormat(line))
                {
                    return;
                }
            }
            IO.WriteLineSuccess("All formats added successfully.");
        }