/// <summary> /// Use saved credentials if omitted. /// </summary> /// <param name="credentialRepository"> /// A <see cref="ICredentialRepository"/> to load saved credentials from. /// </param> /// <param name="server"> /// The server name. This cannot be null, empty or whitespace. /// </param> /// <param name="suppliedUserName"> /// The user name given on the command line. Use the stored one if null. /// </param> /// <param name="suppliedPassword"> /// The password given on the command line. Use the stored one if null. /// </param> /// <param name="userName"> /// Receives the user name. /// </param> /// <param name="password"> /// Received the password. /// </param> /// <exception cref="ArgumentException"> /// <paramref name="server"/> cannot be null, empty or whitespace. /// </exception> /// <exception cref="CredentialNotFoundException"> /// No credentials are specified or saved for that server. /// </exception> private static void GetCredentials(ICredentialRepository credentialRepository, string server, string suppliedUserName, string suppliedPassword, out string userName, out string password) { if (string.IsNullOrWhiteSpace(suppliedUserName) || string.IsNullOrWhiteSpace(suppliedPassword)) { credentialRepository.Load(server, out userName, out password); } else { userName = suppliedUserName; password = suppliedPassword; } }