Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        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);
        }