Skip to content

Commit

Permalink
Update constructor
Browse files Browse the repository at this point in the history
Added new constructors to the connector to be more flexible
  • Loading branch information
Andreas Pouwels committed Apr 21, 2020
1 parent 1053849 commit 5cdfb9a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ZimLabs.Database.MySql/Connector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,34 @@ public Connector(DatabaseSettings settings)
CreateConnectionString();
}

/// <summary>
/// Creates a new instance of the <see cref="Connector"/>
/// </summary>
/// <param name="server">The name / path of the server</param>
/// <param name="database">The name of the database</param>
/// <param name="userId">The user id</param>
/// <param name="password">The password</param>
/// <param name="port">The port (optional)</param>
public Connector(string server, string database, string userId, string password, uint port = 3306) : this(
new DatabaseSettings(server, database, userId, password.ToSecureString(), port))
{

}

/// <summary>
/// Creates a new instance of the <see cref="Connector"/>
/// </summary>
/// <param name="server">The name / path of the server</param>
/// <param name="database">The name of the database</param>
/// <param name="userId">The user id</param>
/// <param name="password">The password</param>
/// <param name="port">The port (optional)</param>
public Connector(string server, string database, string userId, SecureString password, uint port = 3306) : this(
new DatabaseSettings(server, database, userId, password, port))
{

}

/// <summary>
/// Creates a new instance of the <see cref="Connector"/>
/// </summary>
Expand Down
22 changes: 22 additions & 0 deletions ZimLabs.Database.MySql/DatabaseSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,27 @@ public class DatabaseSettings
/// Gets or sets the port
/// </summary>
public uint Port { get; set; }

/// <summary>
/// Creates a new empty instance of the <see cref="DatabaseSettings"/>
/// </summary>
public DatabaseSettings(){ }

/// <summary>
/// Creates a new instance of the <see cref="DatabaseSettings"/>
/// </summary>
/// <param name="server">The name / path of the server</param>
/// <param name="database">The name of the database</param>
/// <param name="userId">The user id</param>
/// <param name="password">The password</param>
/// <param name="port">The port (optional)</param>
public DatabaseSettings(string server, string database, string userId, SecureString password, uint port = 3306)
{
Server = server;
Database = database;
UserId = userId;
Password = password;
Port = port;
}
}
}

0 comments on commit 5cdfb9a

Please sign in to comment.