using System;
namespace Butterfly.Storage
{
///
/// Represents a database server and holds information about the database host, port and access credentials.
///
internal class DatabaseServer
{
#region Fields
private readonly string mHost;
private readonly uint mPort;
private readonly string mUser;
private readonly string mPassword;
#endregion
#region Properties
///
/// The network host of the database server, eg 'localhost' or '127.0.0.1'.
///
internal string Host
{
get { return mHost; }
}
///
/// The network port of the database server as an unsigned 32 bit integer.
///
internal uint Port
{
get { return mPort; }
}
///
/// The username to use when connecting to the database.
///
internal string User
{
get { return mUser; }
}
///
/// The password to use in combination with the username when connecting to the database.
///
internal string Password
{
get { return mPassword; }
}
#endregion
#region Constructor
///
/// Constructs a DatabaseServer object with given details.
///
/// The network host of the database server, eg 'localhost' or '127.0.0.1'.
/// The network port of the database server as an unsigned 32 bit integer.
/// The username to use when connecting to the database.
/// The password to use in combination with the username when connecting to the database.
internal DatabaseServer(string sHost, uint Port, string sUser, string sPassword)
{
if (sHost == null || sHost.Length == 0)
throw new ArgumentException("sHost is null or empty");
if (sUser == null || sUser.Length == 0)
throw new ArgumentException("sUser is null or empty");
mHost = sHost;
mPort = Port;
mUser = sUser;
mPassword = (sPassword != null) ? sPassword : "";
}
#endregion
#region Methods
public override string ToString()
{
return mUser + "@" + mHost;
}
#endregion
}
}