Skip to content

Commit 313d21f

Browse files
thargybillings7
authored andcommittedOct 4, 2016
#24 Added new manual disposal overloads to SqlProgram. If you provide a lambda that takes an IDisposable parameter, then you can dispose the resources manually by calling Dispose() on the supplied object.
Disposal occurs automatically once command timeout +1s has elapsed, making it less likely for resource leaks to occur. Also added an overload to the constructor of CloseableStream to accept an IDisposable directly. Tests have been updated, as have Test databases.
1 parent 18618c0 commit 313d21f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+19466
-1066
lines changed
 

‎Database/ConcurrencyController.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ private static void UpdateSemaphore<TId>(
236236
/// <exception cref="System.ArgumentNullException"><paramref name="databaseId"/> was null.</exception>
237237
public static AsyncSemaphore GetDatabaseSemaphore([NotNull] string databaseId)
238238
{
239-
if (databaseId == null) throw new ArgumentNullException("databaseId");
239+
if (databaseId == null) throw new ArgumentNullException(nameof(databaseId));
240240

241241
AsyncSemaphore semaphore;
242242
_databaseSemaphores.TryGetValue(databaseId, out semaphore);
@@ -254,8 +254,8 @@ public static AsyncSemaphore GetLoadBalancedConnectionSemaphore(
254254
[NotNull] string databaseId,
255255
[NotNull] string connectionId)
256256
{
257-
if (databaseId == null) throw new ArgumentNullException("databaseId");
258-
if (connectionId == null) throw new ArgumentNullException("connectionId");
257+
if (databaseId == null) throw new ArgumentNullException(nameof(databaseId));
258+
if (connectionId == null) throw new ArgumentNullException(nameof(connectionId));
259259

260260
AsyncSemaphore semaphore;
261261
_loadBalancedConnectionSemaphores.TryGetValue(new Id(databaseId, connectionId), out semaphore);
@@ -275,9 +275,9 @@ public static AsyncSemaphore GetConnectionSemaphore(
275275
[NotNull] string connectionId,
276276
[NotNull] Connection connection)
277277
{
278-
if (databaseId == null) throw new ArgumentNullException("databaseId");
279-
if (connectionId == null) throw new ArgumentNullException("connectionId");
280-
if (connection == null) throw new ArgumentNullException("connection");
278+
if (databaseId == null) throw new ArgumentNullException(nameof(databaseId));
279+
if (connectionId == null) throw new ArgumentNullException(nameof(connectionId));
280+
if (connection == null) throw new ArgumentNullException(nameof(connection));
281281

282282
AsyncSemaphore semaphore;
283283
_connectionSemaphores.TryGetValue(new ConnectionId(databaseId, connectionId, connection), out semaphore);
@@ -295,8 +295,8 @@ public static AsyncSemaphore GetProgramSemaphore(
295295
[NotNull] string databaseId,
296296
[NotNull] string programName)
297297
{
298-
if (databaseId == null) throw new ArgumentNullException("databaseId");
299-
if (programName == null) throw new ArgumentNullException("programName");
298+
if (databaseId == null) throw new ArgumentNullException(nameof(databaseId));
299+
if (programName == null) throw new ArgumentNullException(nameof(programName));
300300

301301
AsyncSemaphore semaphore;
302302
_programSemaphores.TryGetValue(new Id(databaseId, programName), out semaphore);

‎Database/Configuration/DatabaseElement.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public async Task<SqlProgram> GetSqlProgram(
163163
TypeConstraintMode? constraintMode = null,
164164
CancellationToken cancellationToken = default(CancellationToken))
165165
{
166-
if (name == null) throw new ArgumentNullException("name");
166+
if (name == null) throw new ArgumentNullException(nameof(name));
167167

168168
// Grab the default load balanced connection for the database.
169169
// ReSharper disable once PossibleNullReferenceException

0 commit comments

Comments
 (0)