[Roam-commit] SF.net SVN: roam: [87] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-07-25 06:31:18
|
Revision: 87
http://roam.svn.sourceforge.net/roam/?rev=87&view=rev
Author: jonfroehlich
Date: 2007-07-24 23:31:17 -0700 (Tue, 24 Jul 2007)
Log Message:
-----------
attempted to squash bug #1706500 found by sakowiczm, which is: I forgot to finish my implementation of SqlCeWrapper. I left both the Open/Close methods unfinished. I completed this and added a reference count property which counts the number of open connections. I have not yet tested these changes.
Modified Paths:
--------------
Trunk/Source/Roam.SqlCe/SqlCeWrapper.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.SqlCe/SqlCeWrapper.cs
===================================================================
--- Trunk/Source/Roam.SqlCe/SqlCeWrapper.cs 2007-07-24 07:40:33 UTC (rev 86)
+++ Trunk/Source/Roam.SqlCe/SqlCeWrapper.cs 2007-07-25 06:31:17 UTC (rev 87)
@@ -33,13 +33,30 @@
{
private static SqlCeConnection _sqlCeConnection;
private static object _objLock = new object();
+ private static int _referenceCount = 0;
+ public static int ReferenceCount
+ {
+ get { return _referenceCount; }
+ }
+
+ public static bool IsOpened
+ {
+ get { return _sqlCeConnection != null; }
+ }
+
public static void Open(string connectionString)
{
lock (_objLock)
{
- if (_sqlCeConnection != null) throw new InvalidOperationException("Connection already open.");
- _sqlCeConnection = new SqlCeConnection(connectionString);
+ if (_sqlCeConnection != null )
+ {
+ _sqlCeConnection = new SqlCeConnection(connectionString);
+ _referenceCount = 0;
+ }
+
+ _sqlCeConnection.Open();
+ _referenceCount++;
}
}
@@ -47,10 +64,14 @@
{
lock (_objLock)
{
- if (_sqlCeConnection != null)
+ _referenceCount--;
+
+ if (_sqlCeConnection != null && _referenceCount <= 0)
{
+ _sqlCeConnection.Close();
_sqlCeConnection.Dispose();
_sqlCeConnection = null;
+ _referenceCount = 0;
}
}
}
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|