Esempio n. 1
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);
    }
Esempio n. 2
0
    public static string?AskSwitch(string question, List <string> options)
    {
        var cs = new ConsoleSwitch <int, string>(question);

        for (int i = 0; i < options.Count; i++)
        {
            cs.Add(i, options[i]);
        }

        return(cs.Choose());
    }