Exemplo n.º 1
0
        /// <summary>
        /// Override of the base method for <code>BeginProcessing()</code>.
        /// This override method handles instantiation and preparation of the passed
        /// information in the command.
        /// </summary>
        /// <exception cref="InvalidGitRepoException">
        /// Invalid git parameter entry will trigger this exception and halt the command.
        /// </exception>
        /// <seealso cref="GitParamType"/>
        /// <seealso cref="Processor.ValidateGitParam(string)"/>
        /// <seealso cref="CmdContainer"/>
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            // prepare container
            GitParamType gitType = Processor.ValidateGitParam(GitRepo);

            if (gitType == GitParamType.INVALID)
            {
                throw new InvalidGitRepoException();
            }
            else
            {
                _cmdContainer = new CmdContainer(
                    url: (gitType == GitParamType.URL ? GitRepo : Processor.CreateRepoURL(GitRepo)),
                    repoName: (gitType == GitParamType.REPO_NAME ? GitRepo : Processor.CreateRepoName(GitRepo)),
                    branch: this.Branch,
                    stopExecute: this.StopExecute.IsPresent,
                    vsVersion: this.VSVersion,
                    exit: this.Exit.IsPresent,
                    fsCurrentDirectory: SessionState.Path.CurrentFileSystemLocation.ToString()
                    );

                Directory.SetCurrentDirectory(_cmdContainer.RootPath);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Collects the sln file path of the repo from its directory.
 /// </summary>
 /// <returns>The message string of the result. If empty string, no message needs passed back (success)</returns>
 private static string GetSlnFilePath(ref CmdContainer cmdContainer)
 {
     try
     {
         cmdContainer.SlnFile = ((new DirectoryInfo(cmdContainer.RepoPath)).GetFiles(FileSearchPattern, SearchOption.AllDirectories).OrderByDescending(f => f.LastWriteTime).First()).FullName.ToString();
         return(UIMessage_SlnFound);
     }
     catch
     {
         cmdContainer.HaltExecution();
         return(UIMessage_NoSlnFound);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the VS path to launch the repo's sln file.
        /// </summary>
        private static void ExecuteVS(CmdContainer cmdContainer, string vsExePath)
        {
            switch (vsExePath)
            {
            case null:
                Process.Start(cmdContainer.SlnFile);
                break;

            default:
                Process.Start(vsExePath, cmdContainer.SlnFile);
                break;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Launches Visual Studio. If no parameter was passed by VSVersion, launches the default application.
        /// </summary>
        /// <param name="cmdContainer">The <see cref="CmdContainer"/> holding the information needed by this process.</param>
        /// <returns>Messages of what this process has done.</returns>
        /// <seealso cref="CmdContainer"/>
        /// <seealso cref="ConstMgr"/>
        /// <seealso cref="DetermineVSInfo(double?)"/>
        internal static string LaunchVS(CmdContainer cmdContainer)
        {
            string displayMessage = GetSlnFilePath(ref cmdContainer);

            if (cmdContainer.StopExecute)
            {
                return(displayMessage);
            }
            else
            {
                // Must both have a sln file found, as well as set to execute
                (string vsMessage, string exePath) = DetermineVSInfo(cmdContainer.VSVersion);
                ExecuteVS(cmdContainer, exePath);
                return(displayMessage + vsMessage);
            }
        }