SourceForge has been redesigned. Learn more.
Close

Diff of /System.Data.SQLite/SQLiteConnectionHandle.cs [000000] .. [8e2213]  Maximize  Restore

Switch to side-by-side view

--- a
+++ b/System.Data.SQLite/SQLiteConnectionHandle.cs
@@ -0,0 +1,48 @@
+ďťżusing System.Runtime.InteropServices;
+
+namespace System.Data.SQLite
+{
+    /// <summary>
+    /// Handles the unmanaged database pointer, and provides finalization support for it.
+    /// </summary>
+    internal class SQLiteConnectionHandle : CriticalHandle
+    {
+        public static implicit operator IntPtr(SQLiteConnectionHandle db)
+        {
+            return db.handle;
+        }
+
+        public static implicit operator SQLiteConnectionHandle(IntPtr db)
+        {
+            return new SQLiteConnectionHandle(db);
+        }
+
+        private SQLiteConnectionHandle(IntPtr db)
+            : this()
+        {
+            SetHandle(db);
+        }
+
+        internal SQLiteConnectionHandle()
+            : base(IntPtr.Zero)
+        {
+        }
+
+        protected override bool ReleaseHandle()
+        {
+            try
+            {
+                SQLiteBase.CloseConnection(this);
+            }
+            catch (SQLiteException)
+            {
+            }
+            return true;
+        }
+
+        public override bool IsInvalid
+        {
+            get { return (handle == IntPtr.Zero); }
+        }
+    }
+}