Esempio n. 1
0
        public static void SendMessageAsReflection <T>(this UserAbstract user, string name, T value)
        {
            var lines = value.ToPrintableLines();

            user.SendMessage();
            user.SendMessage($"== {name} ==");

            for (int i = 0; i < lines.Count; i++)
            {
                var line   = lines[i];
                var prefix = new string(' ', (line.Level + 1) * 4);
                user.SendMessage($"{prefix}{line.Message}");
            }
        }
Esempio n. 2
0
        public static List <T> ReadInputWhileBreak <T>(this UserAbstract user, string message, Func <UserAbstract, InputResult, T> func)
        {
            var list = new List <T>();

            while (true)
            {
                user.SendMessage(message);
                user.SendMessage(user.GetBreakMessage());

                var input = user.ReadInput();

                if (user.IsBreak(input.AsString) == true)
                {
                    break;
                }
                else
                {
                    var v = func(user, input);
                    list.Add(v);
                }
            }

            return(list);
        }
Esempio n. 3
0
 public static List <InputResult> ReadInputWhileBreak(this UserAbstract user, string message)
 {
     return(ReadInputWhileBreak(user, message, (u, ir) => ir));
 }