public void Init(string parameter) //this method is used to add a new directory to my directory list { if (Directory.Exists(parameter)) { foreach (DirectoryVersion dir in DirectoryList) { if (parameter == dir.Path) { Console.WriteLine("Путь уже инициализирован."); //the path was already initialized return; } } ActiveDirectory = new DirectoryVersion() { Path = parameter }; ActiveDirectory.Init(); DirectoryList.Add(ActiveDirectory); Console.WriteLine("Путь инициализирован. Папка добавлена в список."); //the path was initialized. The folder was added to the list } else { Console.WriteLine("Ошибка: Указанного пути не существует."); //error. The path doesn't exist } }
public void Checkout(string parameter) //here we choose the other active directory { if (int.TryParse(parameter, out int i)) //would be cool if a user just uses an index... { ActiveDirectory = DirectoryList[i - 1]; Console.WriteLine("Отслеживаемая папка: {0}", ActiveDirectory.Path); //the folder we work in rn return; } else if (!Directory.Exists(parameter)) //...cause if not, that guy with crooky fingers might misspell the path again { Console.WriteLine("Ошибка: Указанный путь не существует."); //error. The path doesn't exist. return; } else { int inddir = DirectoryList.FindIndex(item => item.Path == parameter); //getting the index. Told you that indexes are cool. if (inddir == -1) { Console.WriteLine("Ошибка: Данная папка не инициализирована."); //the folder is not in DirectoryList return; } ActiveDirectory = DirectoryList[inddir]; Console.WriteLine("Отслеживаемая папка: {0}", ActiveDirectory.Path); //the folder we work in rn return; } }