internal static void ShowSelectedIndexMenu(ICodeSearcherManager manager, ICodeSearcherIndex selectedIndex, ITextBasedUserInterface tui, IMenuNavigator nav) { string answer; do { tui.WriteLine($"ID:\t\t{selectedIndex.ID}"); tui.WriteLine($"Source:\t\t{selectedIndex.SourcePath}"); tui.Write($"File Extensions:\t\t"); foreach (var extension in selectedIndex.FileExtensions) { tui.Write($"{extension}, "); } tui.WriteLine(); tui.WriteLine($"Created on: {selectedIndex.CreatedTime.ToString("yyyy-MM-dd H:mm:ss")}"); tui.WriteLine("[1] Search in Index"); tui.WriteLine("[2] Delete Index"); tui.WriteLine("[3] Return to main menu"); tui.WriteLine("Please choose: "); answer = tui.ReadLine(); if (int.TryParse(answer, out int selection)) { if (1.Equals(selection)) { var logic = GetCodeSearcherLogicByIndex(selectedIndex); logic.SearchWithinExistingIndex( startCallback: () => { }, getSearchWord: () => { bool exit = ReadWordToSearch(out string word); word?.Trim(); return(word, exit); }, getMaximumNumberOfHits: () => { return(200); }, getHitsPerPage: () => { return(50); }, getExporter: () => { return(false, null); }, getSingleResultPrinter: () => { return(new WildcardResultPrinter()); }, finishedCallback: (timeSpan) => { Console.WriteLine("Press any key to continue"); Console.ReadKey(); }, endOfSearchCallback: () => { }, wildcardSearch: true ); } else if (2.Equals(selection)) { manager.DeleteIndex(selectedIndex.ID); tui.WriteLine($"Index with ID {selectedIndex.ID} deleted!"); } else if (3.Equals(selection)) { nav.GoToMainMenu(tui); } } } while (tui.ShouldLoop()); }
public bool Equals(ICodeSearcherIndex other) { if (other == null) { return(false); } return(ID == other.ID); }
private static ICodeSearcherLogic GetCodeSearcherLogicByIndex(ICodeSearcherIndex selectedIndex) { return(Factory.Get().GetCodeSearcherLogic( new LoggerAdapter(m_Logger), getIndexPath: () => selectedIndex.IndexPath, getSourcePath: () => selectedIndex.SourcePath, getFileExtension: () => selectedIndex.FileExtensions )); }
public int GetHashCode(ICodeSearcherIndex obj) { return(obj.GetHashCode()); }
public bool Equals(ICodeSearcherIndex x, ICodeSearcherIndex y) { return(x.GetHashCode() == y.GetHashCode()); }
/// <inheritdoc /> public void GoToSelectedIndexMenu(ICodeSearcherManager manager, ICodeSearcherIndex selectedIndex, ITextBasedUserInterface tui) { Program.ShowSelectedIndexMenu(manager, selectedIndex, tui, this); tui.SetShouldLoop(false); }