Harden disposal paths and test project metadata
This commit is contained in:
@@ -260,35 +260,51 @@ namespace DynamORM
|
||||
|
||||
#region IExtendedDisposable Members
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
lock (_db.SyncLock)
|
||||
{
|
||||
if (_con != null)
|
||||
{
|
||||
List<IDbCommand> pool = _db.CommandsPool.TryGetValue(_con.Connection);
|
||||
|
||||
if (pool != null && pool.Contains(this))
|
||||
pool.Remove(this);
|
||||
}
|
||||
|
||||
IsDisposed = true;
|
||||
|
||||
if (_command != null)
|
||||
{
|
||||
_command.Parameters.Clear();
|
||||
|
||||
_command.Dispose();
|
||||
_command = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
var db = _db;
|
||||
if (db == null)
|
||||
{
|
||||
IsDisposed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
lock (db.SyncLock)
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
IsDisposed = true;
|
||||
|
||||
if (_con != null)
|
||||
{
|
||||
List<IDbCommand> pool = db.CommandsPool.TryGetValue(_con.Connection);
|
||||
|
||||
if (pool != null && pool.Contains(this))
|
||||
pool.Remove(this);
|
||||
}
|
||||
|
||||
if (_command != null)
|
||||
{
|
||||
_command.Parameters.Clear();
|
||||
|
||||
_command.Dispose();
|
||||
_command = null;
|
||||
}
|
||||
|
||||
_con = null;
|
||||
_db = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
#endregion IExtendedDisposable Members
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user