Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 42 additions & 11 deletions src/Npgsql/NpgsqlConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,8 @@ public NpgsqlConnection()
{
}

/// <summary>
/// Initializes a new instance of the
/// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
/// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
/// </summary>
/// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
public NpgsqlConnection(String ConnectionString)
private void Init()
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");

LoadConnectionStringBuilder(ConnectionString);

NoticeDelegate = new NoticeEventHandler(OnNotice);
NotificationDelegate = new NotificationEventHandler(OnNotification);

Expand All @@ -186,6 +176,36 @@ public NpgsqlConnection(String ConnectionString)
promotable = new NpgsqlPromotableSinglePhaseNotification(this);
}

/// <summary>
/// Initializes a new instance of the
/// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
/// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
/// </summary>
/// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
public NpgsqlConnection(String ConnectionString)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");

LoadConnectionStringBuilder(ConnectionString);

Init();
}

/// <summary>
/// Initializes a new instance of the
/// <see cref="Npgsql.NpgsqlConnection">NpgsqlConnection</see> class
/// and sets the <see cref="Npgsql.NpgsqlConnection.ConnectionString">ConnectionString</see>.
/// </summary>
/// <param name="ConnectionString">The connection used to open the PostgreSQL database.</param>
public NpgsqlConnection(NpgsqlConnectionStringBuilder ConnectionString)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, "NpgsqlConnection()");

LoadConnectionStringBuilder(ConnectionString);

Init();
}

/// <summary>
/// Gets or sets the string used to connect to a PostgreSQL database.
/// Valid values are:
Expand Down Expand Up @@ -1039,6 +1059,17 @@ private void LoadConnectionStringBuilder(string connectionString)
LogConnectionString();
}

/// <summary>
/// Sets the `settings` ConnectionStringBuilder based on the given `connectionString`
/// </summary>
/// <param name="connectionString">The connection string to load the builder from</param>
private void LoadConnectionStringBuilder(NpgsqlConnectionStringBuilder connectionString)
{
settings = connectionString;
RefreshConnectionString();
LogConnectionString();
}

/// <summary>
/// Refresh the cached _connectionString whenever the builder settings change
/// </summary>
Expand Down
Loading