public static T[]? ChooseConsoleMultiple <T>(this IEnumerable <T> collection, Func <T, string>?getString = null, string?message = null) where T : class { var cs = new ConsoleSwitch <int, T>(message ?? ConsoleMessage.SelectOneOfTheFollowingOptions.NiceToString()); cs.Load(collection.ToList(), getString); return(cs.ChooseMultiple()); }
public static T ChooseConsole <T>(this List <T> collection, Func <T, string> getString = null) where T : class { var cs = new ConsoleSwitch <int, T>(); cs.Load(collection, getString); return(cs.Choose()); }
public static string AskSwitch(string question, List <string> options) { var cs = new ConsoleSwitch <int, string>(); for (int i = 0; i < options.Count; i++) { cs.Add(i, options[i]); } return(cs.Choose(question)); }
public static T[] ChooseConsoleMultiple <T>(this IEnumerable <T> collection, Func <T, string> getString = null, string message = null) where T : class { if (message != null) { Console.WriteLine(message); } var cs = new ConsoleSwitch <int, T>(); cs.Load(collection.ToList(), getString); return(cs.ChooseMultiple()); }
public static T ChooseConsoleWithFilter <T>(this IEnumerable <T> collection, Func <T, bool> predicate, Func <T, string> getString = null, string message = null) where T : class { if (message != null) { Console.WriteLine(message); } var cs = new ConsoleSwitch <int, T>(); cs.Load(collection.Where(predicate).ToList(), getString); return(cs.Choose()); }
public static ConsoleSwitch <int, T> Load <T>(this ConsoleSwitch <int, T> cs, List <T> collection, Func <T, string>?getString = null) where T : class { for (int i = 0; i < collection.Count; i++) { var item = collection[i]; if (getString != null) { cs.Add(i, item, getString(item)); } else { cs.Add(i, item); } } return(cs); }