From: Michael D. <mik...@us...> - 2005-01-16 19:55:52
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13816/NHibernate/Impl Modified Files: EnumerableImpl.cs Log Message: NH-183: EnumerableImpl now implements IDisposable. Index: EnumerableImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/EnumerableImpl.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** EnumerableImpl.cs 31 Dec 2004 19:51:20 -0000 1.8 --- EnumerableImpl.cs 16 Jan 2005 19:55:42 -0000 1.9 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using System.Data; *************** *** 13,17 **** /// This is the IteratorImpl in H2.0.3 /// </remarks> ! internal class EnumerableImpl : IEnumerable, IEnumerator { private static readonly ILog log = LogManager.GetLogger( typeof( EnumerableImpl ) ); --- 14,18 ---- /// This is the IteratorImpl in H2.0.3 /// </remarks> ! internal class EnumerableImpl : IEnumerable, IEnumerator, IDisposable { private static readonly ILog log = LogManager.GetLogger( typeof( EnumerableImpl ) ); *************** *** 148,152 **** } } ! } \ No newline at end of file --- 149,175 ---- } + #region IDisposable Members + /// <summary> + /// Releases resources that the EnumerableImpl acquired. + /// </summary> + /// <remarks> + /// The command is closed and the reader is disposed. This allows other ADO.NET + /// related actions to occur without needing to move all the way through the + /// EnumerableImpl. + /// </remarks> + public void Dispose() + { + log.Debug( "disposing of enumerator" ); + // if there is still a possibility of moving next then we need to clean up + // the resources - otherwise the cleanup has already been done. + if( _hasNext ) + { + _currentResults = null; + _sess.Batcher.CloseQueryCommand( _cmd, _reader ); + } + } + + #endregion } ! } |