Harden disposal paths and test project metadata
This commit is contained in:
@@ -960,14 +960,17 @@ namespace DynamORM.Builders.Implementation
|
||||
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
IsDisposed = true;
|
||||
|
||||
if (Database != null)
|
||||
Database.RemoveFromCache(this);
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
IsDisposed = true;
|
||||
|
||||
if (Database != null)
|
||||
Database.RemoveFromCache(this);
|
||||
|
||||
if (Parameters != null)
|
||||
{
|
||||
@@ -994,4 +997,4 @@ namespace DynamORM.Builders.Implementation
|
||||
|
||||
#endregion IExtendedDisposable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,9 @@ namespace DynamORM
|
||||
internal IList<object> _cache;
|
||||
}
|
||||
|
||||
private List<Data> _data = new List<Data>();
|
||||
private int _currentDataPosition = 0;
|
||||
private List<Data> _data = new List<Data>();
|
||||
private int _currentDataPosition = 0;
|
||||
private bool _isDisposed;
|
||||
|
||||
private DynamicCachedReader()
|
||||
{
|
||||
@@ -443,18 +444,34 @@ namespace DynamORM
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var data in _data)
|
||||
{
|
||||
data._names.Clear();
|
||||
data._types.Clear();
|
||||
data._cache.Clear();
|
||||
data._schema.Dispose();
|
||||
}
|
||||
|
||||
_data.Clear();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
_isDisposed = true;
|
||||
IsClosed = true;
|
||||
|
||||
if (_data == null)
|
||||
return;
|
||||
|
||||
foreach (var data in _data)
|
||||
{
|
||||
if (data == null)
|
||||
continue;
|
||||
|
||||
if (data._names != null)
|
||||
data._names.Clear();
|
||||
if (data._types != null)
|
||||
data._types.Clear();
|
||||
if (data._cache != null)
|
||||
data._cache.Clear();
|
||||
if (data._schema != null)
|
||||
data._schema.Dispose();
|
||||
}
|
||||
|
||||
_data.Clear();
|
||||
}
|
||||
|
||||
#endregion IDisposable Members
|
||||
|
||||
@@ -721,4 +738,4 @@ namespace DynamORM
|
||||
|
||||
#endregion IDataRecord Members
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,17 +161,25 @@ namespace DynamORM
|
||||
|
||||
#region IExtendedDisposable Members
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with freeing,
|
||||
/// releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
_db.Close(Connection);
|
||||
IsDisposed = true;
|
||||
}
|
||||
/// <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 && Connection != null)
|
||||
db.Close(Connection);
|
||||
|
||||
Connection = null;
|
||||
_db = null;
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
||||
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
#endregion IExtendedDisposable Members
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2006,13 +2006,16 @@ namespace DynamORM
|
||||
|
||||
#region IExtendedDisposable Members
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with freeing,
|
||||
/// releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
#if !DYNAMORM_OMMIT_OLDSYNTAX
|
||||
List<DynamicTable> tables = TablesCache.Values.ToList();
|
||||
TablesCache.Clear();
|
||||
/// <summary>Performs application-defined tasks associated with freeing,
|
||||
/// releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
#if !DYNAMORM_OMMIT_OLDSYNTAX
|
||||
List<DynamicTable> tables = TablesCache.Values.ToList();
|
||||
TablesCache.Clear();
|
||||
|
||||
tables.ForEach(t => t.Dispose());
|
||||
tables.Clear();
|
||||
@@ -2063,16 +2066,18 @@ namespace DynamORM
|
||||
RemainingBuilders = null;
|
||||
}
|
||||
|
||||
ClearSchema();
|
||||
if (_proc != null)
|
||||
_proc.Dispose();
|
||||
|
||||
IsDisposed = true;
|
||||
}
|
||||
ClearSchema();
|
||||
if (_proc != null)
|
||||
_proc.Dispose();
|
||||
|
||||
_proc = null;
|
||||
_tempConn = null;
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
||||
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
#endregion IExtendedDisposable Members
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,11 @@ namespace DynamORM
|
||||
/// public class ProcResult { [Column("outp")] public Guid Output { get; set; } }
|
||||
/// ProcResult res4 = db.Procedures.sp_Test_Scalar_In_Out<ProcResult>(inp: Guid.NewGuid(), out_outp: Guid.Empty) as ProcResult;
|
||||
/// </code>As you can se, you can use mapper to do job for you.</example>
|
||||
public class DynamicProcedureInvoker : DynamicObject, IDisposable
|
||||
{
|
||||
private DynamicDatabase _db;
|
||||
private List<string> _prefixes;
|
||||
public class DynamicProcedureInvoker : DynamicObject, IDisposable
|
||||
{
|
||||
private DynamicDatabase _db;
|
||||
private List<string> _prefixes;
|
||||
private bool _isDisposed;
|
||||
|
||||
internal DynamicProcedureInvoker(DynamicDatabase db, List<string> prefixes = null)
|
||||
{
|
||||
@@ -446,10 +447,16 @@ namespace DynamORM
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
_isDisposed = true;
|
||||
_db = null;
|
||||
_prefixes = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -950,15 +950,18 @@ namespace DynamORM
|
||||
|
||||
#region IExtendedDisposable Members
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
// Lose reference but don't kill it.
|
||||
if (Database != null)
|
||||
{
|
||||
Database.RemoveFromCache(this);
|
||||
Database = null;
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
// Lose reference but don't kill it.
|
||||
if (Database != null)
|
||||
{
|
||||
Database.RemoveFromCache(this);
|
||||
Database = null;
|
||||
}
|
||||
|
||||
IsDisposed = true;
|
||||
@@ -989,4 +992,4 @@ namespace DynamORM
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,20 +170,27 @@ namespace DynamORM
|
||||
|
||||
#region IExtendedDisposable Members
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
_isDisposed = true;
|
||||
Rollback();
|
||||
|
||||
if (_disposed != null)
|
||||
_disposed();
|
||||
}
|
||||
/// <summary>Performs application-defined tasks associated with
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
_isDisposed = true;
|
||||
Rollback();
|
||||
|
||||
if (_disposed != null)
|
||||
_disposed();
|
||||
|
||||
_disposed = null;
|
||||
_con = null;
|
||||
_db = null;
|
||||
}
|
||||
|
||||
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
||||
public bool IsDisposed { get { return !_isOperational; } }
|
||||
|
||||
#endregion IExtendedDisposable Members
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1444,15 +1444,18 @@ namespace DynamORM.Helpers.Dynamics
|
||||
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
IsDisposed = true;
|
||||
|
||||
if (_uncertainResult != null)
|
||||
{
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
IsDisposed = true;
|
||||
|
||||
if (_uncertainResult != null)
|
||||
{
|
||||
if (_uncertainResult is Node)
|
||||
((Node)_uncertainResult).Dispose();
|
||||
|
||||
@@ -1486,4 +1489,4 @@ namespace DynamORM.Helpers.Dynamics
|
||||
|
||||
#endregion Implementation of IExtendedDisposable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user