RemoteLoginInfo sanity checking

This commit is contained in:
Cyberboss
2017-11-27 11:34:35 -05:00
parent 283a3e7651
commit 85abbb6aa7
2 changed files with 13 additions and 0 deletions
+11
View File
@@ -20,6 +20,11 @@ namespace TGS.Interface
/// A Windows username for the target server
/// </summary>
public string Username { get; }
/// <summary>
/// Check if the <see cref="RemoteLoginInfo"/> has been initialized with a <see cref="Password"/>
/// </summary>
public bool HasPassword { get { return !String.IsNullOrWhiteSpace(Password); } }
/// <summary>
/// The Windows password for <see cref="Username"/>
/// </summary>
@@ -51,8 +56,14 @@ namespace TGS.Interface
/// <param name="password">The value for <see cref="Password"/></param>
public RemoteLoginInfo(string ip, ushort port, string username, string password)
{
if (String.IsNullOrWhiteSpace(ip))
throw new InvalidOperationException("ip must be set!");
_ip = ip;
if(port == 0)
throw new InvalidOperationException("port may not be 0!");
_port = port;
if (String.IsNullOrWhiteSpace(username))
throw new InvalidOperationException("username must be set!");
_username = username;
_password = password;
}
+2
View File
@@ -216,6 +216,8 @@ namespace TGS.Interface
/// <param name="loginInfo">The <see cref="RemoteLoginInfo"/> for a remote connection</param>
public ServerInterface(RemoteLoginInfo loginInfo)
{
if (!loginInfo.HasPassword)
throw new InvalidOperationException("password must be set on loginInfo!");
_loginInfo = loginInfo;
}