diff --git a/CarManagerV3/SafeManager.cs b/CarManagerV3/SafeManager.cs index cda62b7..4cc396e 100644 --- a/CarManagerV3/SafeManager.cs +++ b/CarManagerV3/SafeManager.cs @@ -8,10 +8,20 @@ using System.Threading.Tasks; namespace CarManagerV3 { + /// + /// Handles safe reading and writing of car data to files. + /// internal class SafeManager { + /// + /// The path of the txt file that contains recently opened file paths. + /// private static readonly string recentPathsFile = "recent_paths.txt"; + /// + /// Initializes a file at a specified path if it does not already exist. + /// + /// The path. public static void InitializeFile(string path) { if (!File.Exists(@path)) @@ -24,6 +34,13 @@ namespace CarManagerV3 } } + /// + /// Reads cars from a specified file path. + /// + /// The path. + /// + /// A containing the cars read from the file. + /// public static List ReadCars(string path) { List cars = new List(); @@ -40,6 +57,11 @@ namespace CarManagerV3 return cars; } + /// + /// Saves the cars to a specified file path. + /// + /// The path. + /// A containing all cars to save. public static void SaveCars(string path, List cars) { using (StreamWriter writer = new StreamWriter(@path)) @@ -51,11 +73,15 @@ namespace CarManagerV3 } } + /// + /// Adds a file path to the recent paths list. + /// If a path is already in the list, it is moved to the top. + /// Otherwise, it is added to the top. + /// Keeps only the 5 most recent paths. + /// + /// The path. public static void AddRecentPath(string path) { - // Read the file, if the path is not already in the file, add it to the top. - // If it is already in the file, move it to the top. - // Keep only the 5 most recent paths. List paths = new List(); if (File.Exists(recentPathsFile)) { @@ -83,6 +109,12 @@ namespace CarManagerV3 } } + /// + /// Gets the recently opened file paths. + /// + /// + /// A containing the recent file paths. + /// public static List GetRecentPaths() { List paths = new List();