Exemplo n.º 1
0
 public TextOutputWriter(CommandBase cmd)
 {
     myCmd = cmd;
 }
Exemplo n.º 2
0
        public ICommandLineAction GetCommand()
        {
            CommandBase cmd = null;

            switch (Command)
            {
            case Commands.CorFlags:
                cmd = new CorFlagsCommand(this);
                break;

            case Commands.Diff:
                cmd = new DiffAssembliesCommand(this);
                break;

            case Commands.MethodUsage:
                cmd = new WhoUsesMethodCommand(this);
                break;

            case Commands.WhoReferences:
                cmd = new WhoReferencesCommand(this);
                break;

            case Commands.DownloadPdbs:
                cmd = new DowndLoadPdbsCommand(this);
                break;

            case Commands.ShowRebuildTargets:
                cmd = new ShowRebuildTargetsCommand(this);
                break;

            case Commands.ShowStrongName:
                cmd = new ShowStrongNameCommand(this);
                break;

            case Commands.ShowReferences:
                cmd = new ShowReferencesCommand(this);
                break;

            case Commands.WhoImplementsInterface:
                cmd = new WhoImplementsInterfaceCommand(this);
                break;

            case Commands.WhoUsesField:
                cmd = new WhoUsesFieldCommand(this);
                break;

            case Commands.WhoUsesEvent:
                cmd = new WhoUsesEventCommand(this);
                break;

            case Commands.WhoUsesStringConstant:
                cmd = new WhoUsesStringConstantCommand(this);
                break;

            case Commands.WhoUsesType:
                cmd = new WhoUsesTypeCommand(this);
                break;

            case Commands.GetFileInfo:
                cmd = new GetFileInfoCommand(this);
                break;

            case Commands.None:
                cmd = new NoneCommand(this);
                break;

            default:
                throw new NotSupportedException(String.Format("Command {0} is not supported", Command));
            }

            if (this.Cwd != null)
            {
                try
                {
                    Directory.SetCurrentDirectory(this.Cwd);
                }
                catch (IOException ex)
                {
                    Console.WriteLine("Error: Could not set current working directory to {0}. Reason: {1}",
                                      this.Cwd, ex.Message);
                    cmd = new NoneCommand(this);
                }

                // Adjust File Queries root directory
                foreach (FileQuery query in this.Queries1)
                {
                    query.UseCwd = true;
                }
                foreach (FileQuery query in this.Queries2)
                {
                    query.UseCwd = true;
                }
                foreach (FileQuery query in this.SearchInQuery)
                {
                    query.UseCwd = true;
                }
            }

            return(cmd);
        }