Ejemplo n.º 1
0
        public static Shell AddCommand(this Shell shell, string pattern, string description,
                                       InvokeShellCommandDelegate invokeHandler, CompleteShellCommandDelegate completeHandler)
        {
            if (shell == null)
            {
                throw new ArgumentNullException(nameof(shell));
            }
            if (invokeHandler == null)
            {
                throw new ArgumentNullException(nameof(invokeHandler));
            }

            var command = new ShellCommand(pattern, description);

            command.InvokeCommand +=
                (sender, args) => { invokeHandler(args.Shell, sender as IShellCommand, args.Arguments); };

            if (completeHandler != null)
            {
                command.CompleteCommand +=
                    (sender, args) =>
                {
                    args.Result = completeHandler(args.Shell, sender as IShellCommand, args.Tokens);
                };
            }

            return(shell.AddCommand(command));
        }
Ejemplo n.º 2
0
        public static Shell AddCommand(this Shell shell, string pattern, string description,
            InvokeShellCommandDelegate invokeHandler, CompleteShellCommandDelegate completeHandler)
        {
            if (shell == null) throw new ArgumentNullException(nameof(shell));
            if (invokeHandler == null) throw new ArgumentNullException(nameof(invokeHandler));

            var command = new ShellCommand(pattern, description);
            command.InvokeCommand +=
                (sender, args) => { invokeHandler(args.Shell, sender as IShellCommand, args.Arguments); };

            if (completeHandler != null)
            {
                command.CompleteCommand +=
                    (sender, args) =>
                    {
                        args.Result = completeHandler(args.Shell, sender as IShellCommand, args.Tokens);
                    };
            }

            return shell.AddCommand(command);
        }
Ejemplo n.º 3
0
 public static Shell AddCommand(this Shell shell, string pattern,
     InvokeShellCommandDelegate invokeHandler)
 {
     return shell.AddCommand(pattern, invokeHandler, null);
 }
Ejemplo n.º 4
0
 public static Shell AddCommand(this Shell shell, string pattern,
                                InvokeShellCommandDelegate invokeHandler)
 {
     return(shell.AddCommand(pattern, invokeHandler, null));
 }