From 7ad878f3ee28a60851f4a1ea6227cfa74cc8b321 Mon Sep 17 00:00:00 2001 From: Sureshkumar T Date: Wed, 2 Feb 2005 10:36:06 +0000 Subject: In System.Data.ProviderBase: 2005-02-02 Sureshkumar T * DbConnectionBase.cs: Implement Dispose Pattern In System.Data.Common: 2005-02-02 Sureshkumar T * DbConnection.cs: Implement Dispose pattern. svn path=/trunk/mcs/; revision=39973 --- mcs/class/System.Data/System.Data.Common/ChangeLog | 4 ++++ .../System.Data/System.Data.Common/DbConnection.cs | 22 ++++++++++++++++++++++ .../System.Data/System.Data.ProviderBase/ChangeLog | 4 ++++ .../System.Data.ProviderBase/DbConnectionBase.cs | 13 +++++++++++-- 4 files changed, 41 insertions(+), 2 deletions(-) (limited to 'mcs') diff --git a/mcs/class/System.Data/System.Data.Common/ChangeLog b/mcs/class/System.Data/System.Data.Common/ChangeLog index 73bdc3d0e31..4c8cd4f57e1 100755 --- a/mcs/class/System.Data/System.Data.Common/ChangeLog +++ b/mcs/class/System.Data/System.Data.Common/ChangeLog @@ -1,3 +1,7 @@ +2005-02-02 Sureshkumar T + + * DbConnection.cs: Implement Dispose pattern. + 2005-01-25 Atsushi Enomoto * DbDataPermission.cs : Empty.Union(Empty) is Empty. diff --git a/mcs/class/System.Data/System.Data.Common/DbConnection.cs b/mcs/class/System.Data/System.Data.Common/DbConnection.cs index e53955ad2f7..3142583ebb3 100644 --- a/mcs/class/System.Data/System.Data.Common/DbConnection.cs +++ b/mcs/class/System.Data/System.Data.Common/DbConnection.cs @@ -39,6 +39,11 @@ using System.EnterpriseServices; namespace System.Data.Common { public abstract class DbConnection : Component, IDbConnection, IDisposable { + + #region Fields + bool disposed = false; + #endregion //Fields + #region Constructors protected DbConnection () @@ -82,6 +87,23 @@ namespace System.Data.Common { return CreateDbCommand (); } + protected override void Dispose (bool disposing) + { + if (!disposed) { + try { + if (disposing) { + // unmanaged cleanup + } + + disposed = true; + } finally { + base.Dispose (disposing); + } + + } + } + + protected abstract DbCommand CreateDbCommand (); [MonoTODO] diff --git a/mcs/class/System.Data/System.Data.ProviderBase/ChangeLog b/mcs/class/System.Data/System.Data.ProviderBase/ChangeLog index a4926fb7407..88301fc8e76 100755 --- a/mcs/class/System.Data/System.Data.ProviderBase/ChangeLog +++ b/mcs/class/System.Data/System.Data.ProviderBase/ChangeLog @@ -1,3 +1,7 @@ +2005-02-02 Sureshkumar T + + * DbConnectionBase.cs: Implement Dispose Pattern + 2004-11-24 Sureshkumar T * DbParameterCollectionBase.cs: Class name changed according to diff --git a/mcs/class/System.Data/System.Data.ProviderBase/DbConnectionBase.cs b/mcs/class/System.Data/System.Data.ProviderBase/DbConnectionBase.cs index 62b413bd99b..377432bb4e5 100644 --- a/mcs/class/System.Data/System.Data.ProviderBase/DbConnectionBase.cs +++ b/mcs/class/System.Data/System.Data.ProviderBase/DbConnectionBase.cs @@ -43,6 +43,7 @@ namespace System.Data.ProviderBase { DbConnectionFactory connectionFactory; DbConnectionString connectionOptions; string connectionString; + bool disposed = false; #endregion // Fields @@ -157,10 +158,18 @@ namespace System.Data.ProviderBase { return (DbCommand) ConnectionFactory.ProviderFactory.CreateCommand (); } - [MonoTODO] protected override void Dispose (bool disposing) { - throw new NotImplementedException (); + if (!disposed) { + try { + if (disposing) { + // do necessary clean up + } + disposed = true; + } finally { + base.Dispose (disposing); + } + } } [MonoTODO] -- cgit v1.2.3