/// <summary>
 /// Method Install.
 /// </summary>
 private void Install()
 {
     if (!WindowsServiceBase.ServiceExists(this._setupInfo.ServiceName))
     {
         WindowsServiceInstaller.RuntimeInstall(this._setupInfo);
     }
     else
     {
         this.WriteToConsole(ConsoleColor.Red, "The specified service already exists.", true, false);
     }
 }
 /// <summary>
 /// Method Uninstall.
 /// </summary>
 private void Uninstall()
 {
     if (WindowsServiceBase.ServiceExists(this._setupInfo.ServiceName))
     {
         WindowsServiceInstaller.RuntimeUninstall(this._setupInfo);
     }
     else
     {
         this.WriteToConsole(ConsoleColor.Red, "The specified service does not exist as an installed service.", true, false);
     }
 }
 /// <summary>
 /// Method WriteCommandInfo.
 /// </summary>
 private void WriteCommandInfo()
 {
     this.WriteToConsole(ConsoleColor.White, string.Format("[O]riginal: {0}", this._windowsService.ServiceSetupInfo.ServiceName).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.White, string.Format("[N]ame:     {0}", this._setupInfo.ServiceName).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.White, string.Format("Mode:       {0}", this.IsConsoleMode ? "Console" : "Service").PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.White, string.Format("Status:     {0}", this.IsConsoleMode ? this._consoleStatus : this.ServiceStatus).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.White, string.Format("Installed:  {0}", WindowsServiceBase.ServiceExists(this._setupInfo.ServiceName)).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.White, " ".PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.White, "[S]tart       S[t]op        [P]ause       [R]esume      R[e]start     ", true, false);
     this.WriteToConsole(ConsoleColor.White, string.Format("{0}[I]nstall     [U]ninstall   St[a]tus      [Q]uit        ", this.IsConsoleMode ? "Ser[v]ice     " : "[C]onsole     "), true, false);
     this.WriteToConsole(ConsoleColor.White, " ".PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.White, "Enter:", false, false);
 }
        /// <summary>
        /// Method Resume.
        /// </summary>
        private void Resume()
        {
            ServiceControllerStatus originalConsoleStatus = this._consoleStatus;

            if (this.IsConsoleMode)
            {
                if (this._consoleStatus == ServiceControllerStatus.Paused)
                {
                    this._consoleStatus = ServiceControllerStatus.ContinuePending;
                    this.WriteToConsole(ConsoleColor.Yellow, string.Format("[Status:] {0}", this._consoleStatus.ToString()));

                    try
                    {
                        this._windowsService.OnContinue();
                        this._consoleStatus = ServiceControllerStatus.Running;
                    }
                    catch (Exception e)
                    {
                        InternalLogger.Log(e);
                        this._consoleStatus = originalConsoleStatus;
                    }
                }

                this.WriteToConsole(ConsoleColor.Yellow, string.Format("[Status:] {0}", this._consoleStatus.ToString()));
            }
            else
            {
                if (WindowsServiceBase.ServiceExists(this._setupInfo.ServiceName))
                {
                    if (this.ServiceStatus == ServiceControllerStatus.Paused)
                    {
                        this.WriteToConsole(ConsoleColor.Yellow, string.Format("[Status:] {0}", this.ServiceStatus.ToString()));
                        WindowsServiceBase.Continue(this._setupInfo.ServiceName);
                    }

                    this.WriteToConsole(ConsoleColor.Yellow, string.Format("[Status:] {0}", this.ServiceStatus.ToString()));
                }
                else
                {
                    this.WriteToConsole(ConsoleColor.Red, "The specified service does not exist as an installed service.", true, false);
                }
            }
        }
 /// <summary>
 /// Method WriteServiceInfo.
 /// </summary>
 private void WriteServiceInfo()
 {
     this.WriteToConsole(ConsoleColor.Yellow, string.Format("Administrator: {0}", new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, string.Format("Service Name:  {0}", this._setupInfo.ServiceName).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, string.Format("Display Name:  {0}", this._setupInfo.DisplayName).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, string.Format("Mode:          {0}", this.IsConsoleMode ? "Console" : "Service").PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, string.Format("Status:        {0}", this.IsConsoleMode ? this._consoleStatus : this.ServiceStatus).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, string.Format("Installed:     {0}", WindowsServiceBase.ServiceExists(this._setupInfo.ServiceName)).PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, "Description:".PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, "    " + this._setupInfo.Description.PadRight(66), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, "Assembly:".PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, "    " + this._setupInfo.ServiceAssembly.FullName.PadRight(66), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, "Assembly File: ".PadRight(70), true, false);
     this.WriteToConsole(ConsoleColor.Yellow, "    " + this._setupInfo.ServiceAssembly.Location.PadRight(66), true, false);
 }