/// <summary> /// Create an instance of the database client. /// </summary> /// <param name="settings">Database settings.</param> public DatabaseClient(DatabaseSettings settings) { _Settings = settings ?? throw new ArgumentNullException(nameof(settings)); if (_Settings.Type != DbTypes.Postgresql) { throw new ArgumentException("Database settings must be of type 'Postgresql'."); } _ConnectionString = PostgresqlHelper.ConnectionString(_Settings); }
/// <summary> /// Create an instance of the database client. /// </summary> /// <param name="serverIp">The IP address or hostname of the database server.</param> /// <param name="serverPort">The TCP port of the database server.</param> /// <param name="username">The username to use when authenticating with the database server.</param> /// <param name="password">The password to use when authenticating with the database server.</param> /// <param name="database">The name of the database with which to connect.</param> public DatabaseClient( string serverIp, int serverPort, string username, string password, string database) { if (String.IsNullOrEmpty(serverIp)) { throw new ArgumentNullException(nameof(serverIp)); } if (serverPort < 0) { throw new ArgumentOutOfRangeException(nameof(serverPort)); } if (String.IsNullOrEmpty(database)) { throw new ArgumentNullException(nameof(database)); } _Settings = new DatabaseSettings(DbTypes.Postgresql, serverIp, serverPort, username, password, database); _ConnectionString = PostgresqlHelper.ConnectionString(_Settings); }