Example #1
0
        public override int PerformCommand( ICommandArgument[] Arguments, out ICommandResult CommandResult )
        {
            if ( Arguments.Length < 2 )
            {
                throw new CommandException();
            }

            System.Uri targetUri = new System.Uri( (string) Arguments[1].GetArgument() );

            _Terminal.WriteTo( new StringBuilder( "Creating request\n" ),
                OutputType.StandardOutput );

            WebRequest searchRequest = WebRequest.Create(
                targetUri );

            _Terminal.WriteTo( new StringBuilder( "Getting request\n" ),
                OutputType.StandardOutput );

            WebResponse searchResult = searchRequest.GetResponse();

            Stream searchStream = searchResult.GetResponseStream();

            ICommandArgument[] showArguments = new ICommandArgument[2];

            showArguments[0] = Arguments[0];
            showArguments[1] = new FileInputArgument( searchStream );

            ShowpageCommand showCommand = new ShowpageCommand( _CommandProcessor, _Terminal );

            return showCommand.PerformCommand( showArguments, out CommandResult );
        }
Example #2
0
        public ICommand GetCommand( string CommandName, ICommandProcessor CommandProcessor )
        {
            ICommand NewCommand = null;

            switch( CommandName )
            {
                case "cd":
                    NewCommand = new ChangeDirCommand( CommandProcessor, _Terminal );
                    break;
                case "cwd":
                    NewCommand = new CurrentDirCommand( CommandProcessor, _Terminal );
                    break;
                case "exit":
                    NewCommand = new ExitCommand( CommandProcessor, _Terminal );
                    break;
                case "prompt":
                    NewCommand = new PromptCommand( CommandProcessor, _Terminal );
                    break;
                case "set":
                    NewCommand = new SetCommand( CommandProcessor, _Terminal );
                    break;
                case "ver":
                    NewCommand = new VersionCommand( CommandProcessor, _Terminal );
                    break;
                case "msn":
                    NewCommand = new MsnCommand( CommandProcessor, _Terminal );
                    break;
                case "page":
                    NewCommand = new PageCommand( CommandProcessor, _Terminal );
                    break;
                case "showpage":
                    NewCommand = new ShowpageCommand( CommandProcessor, _Terminal );
                    break;
                case "textpage":
                    NewCommand = new TextpageCommand( CommandProcessor, _Terminal );
                    break;
            }

            return NewCommand;
        }