예제 #1
0
        public void SetupActions()
        {
            var allMethods = _executionContext.GetType().GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);

            _actionsList = allMethods.Where(m => m.GetCustomAttribute <ConsoleActionTriggerAttribute>() != null).Select(m => new ConsoleAction(m, _executionContext)).ToList();
            _actionsList.Insert(0, new ConsoleAction(Help, "Displays this message", 0, "h", "help", "?"));

            _actions = _actionsList.SelectMany(ca => ca.Commands.Select(c => new KeyValuePair <string, ConsoleAction>(c, ca)))
                       .ToDictionary(k => k.Key, v => v.Value);

            ConsoleHelpers.ConsoleLine("Type '?' or 'help' for additional commands...", ConsoleColor.DarkGray);
        }