From 8b182592348f3bc3880764d2780e9fa2be7ffb2c Mon Sep 17 00:00:00 2001 From: Lucas Schwendler Date: Thu, 30 May 2024 11:01:03 +0200 Subject: [PATCH] feat: change SqlSessionStateProviderAsync.GetConnectionString to allow override --- ...nState.SqlSessionStateProviderAsync.csproj | 2 +- .../SqlSessionStateProviderAsync.cs | 40 +++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/SqlSessionStateProviderAsync/Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj b/src/SqlSessionStateProviderAsync/Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj index a527de7..83a3ee6 100644 --- a/src/SqlSessionStateProviderAsync/Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj +++ b/src/SqlSessionStateProviderAsync/Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.csproj @@ -92,7 +92,7 @@ - 5.0.0 + 5.2.0 diff --git a/src/SqlSessionStateProviderAsync/SqlSessionStateProviderAsync.cs b/src/SqlSessionStateProviderAsync/SqlSessionStateProviderAsync.cs index 7a6b3bf..ec148ed 100644 --- a/src/SqlSessionStateProviderAsync/SqlSessionStateProviderAsync.cs +++ b/src/SqlSessionStateProviderAsync/SqlSessionStateProviderAsync.cs @@ -384,8 +384,29 @@ public override async Task SetAndReleaseItemExclusiveAsync( public override bool SetItemExpireCallback(System.Web.SessionState.SessionStateItemExpireCallback expireCallback) { return false; - } + } + + /// + /// Retrieve the connection string based on the connectionstring name + /// + /// string + /// + protected virtual ConnectionStringSettings GetConnectionString(string connectionstringName) + { + if (string.IsNullOrEmpty(connectionstringName)) + { + throw new ProviderException(SR.Connection_name_not_specified); + } + ConnectionStringSettings conn = ConfigurationManager.ConnectionStrings[connectionstringName]; + if (conn == null) + { + throw new ProviderException( + String.Format(CultureInfo.CurrentCulture, SR.Connection_string_not_found, connectionstringName)); + } + return conn; + } + private async Task DoGet(HttpContextBase context, string id, bool exclusive, CancellationToken cancellationToken) { if (id.Length > SessionIDManager.SessionIDMaxLength) @@ -585,21 +606,6 @@ private void PurgeExpiredSessions() { Interlocked.CompareExchange(ref s_inPurge, 0, 1); } - } - - private static ConnectionStringSettings GetConnectionString(string connectionstringName) - { - if (string.IsNullOrEmpty(connectionstringName)) - { - throw new ProviderException(SR.Connection_name_not_specified); - } - ConnectionStringSettings conn = ConfigurationManager.ConnectionStrings[connectionstringName]; - if (conn == null) - { - throw new ProviderException( - String.Format(CultureInfo.CurrentCulture, SR.Connection_string_not_found, connectionstringName)); - } - return conn; - } + } } }