From 76e1857700532990d424cdaf890c32ed439c5e38 Mon Sep 17 00:00:00 2001 From: YxrWendao Date: Thu, 4 Jun 2020 20:43:33 +0800 Subject: [PATCH] =?UTF-8?q?update=20NFox/Cad/Runtime/DBTransaction.cs.=20?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=9B=B4=E6=8E=A5=E7=94=A8=E4=B8=8B=E5=88=97?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=AE=9E=E7=8E=B0=20void=20IDisposable.Dispo?= =?UTF-8?q?se()=20{=20=20=20Commit();=20=20=20Transaction.Dispose();=20}?= =?UTF-8?q?=20=E5=A5=BD=E5=83=8F=E4=BC=9A=E5=87=BA=E7=8E=B0=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=EF=BC=8C=E5=85=B7=E4=BD=93=E8=AD=A6=E5=91=8A=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=A6=82=E4=B8=8B=EF=BC=9A=20CA1063=09Provide=20an=20?= =?UTF-8?q?overridable=20implementation=20of=20Dispose(bool)=20on=20'DBTra?= =?UTF-8?q?nsaction'=20or=20mark=20the=20type=20as=20sealed.=20A=20call=20?= =?UTF-8?q?to=20Dispose(false)=20should=20only=20clean=20up=20native=20res?= =?UTF-8?q?ources.=20A=20call=20to=20Dispose(true)=20should=20clean=20up?= =?UTF-8?q?=20both=20managed=20and=20native=20resources.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NFox/Cad/Runtime/DBTransaction.cs | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/NFox/Cad/Runtime/DBTransaction.cs b/NFox/Cad/Runtime/DBTransaction.cs index ba5d407..98e1f4e 100644 --- a/NFox/Cad/Runtime/DBTransaction.cs +++ b/NFox/Cad/Runtime/DBTransaction.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -19,7 +19,7 @@ namespace NFox.Cad public class DBTransaction : IDisposable { private bool _commit = false; - + private bool _disposed =false; //属性 #region Properties @@ -162,15 +162,32 @@ namespace NFox.Cad Database.CloseInput(true); Initialize(false); } - /// /// 销毁 /// - void IDisposable.Dispose() + public void Dispose() { - Commit(); - Transaction.Dispose(); + Dispose(true); + GC.SuppressFinalize(this); } + protected virtual void Dispose(bool disposing) + { + if(!this._disposed) + { + if(disposing) + { + Commit(); + Transaction.Dispose(); + } + disposed = true; + } + } + + //void IDisposable.Dispose() + //{ + //Commit(); + //Transaction.Dispose(); + //} /// /// 提交事务 -- Gitee