* OracleTransaction.cs: Corcompare fixes for 2.0 profile. Implemented
[mono.git] / mcs / class / System.Data.OracleClient / System.Data.OracleClient / OracleTransaction.cs
1 //
2 // OracleTransaction.cs 
3 //
4 // Part of the Mono class libraries at
5 // mcs/class/System.Data.OracleClient/System.Data.OracleClient
6 //
7 // Assembly: System.Data.OracleClient.dll
8 // Namespace: System.Data.OracleClient
9 //
10 // Author: Tim Coleman <tim@timcoleman.com>
11 //
12 // Copyright (C) Tim Coleman, 2003
13 //
14 // Licensed under the MIT/X11 License.
15 //
16
17 using System;
18 using System.ComponentModel;
19 using System.Data;
20 using System.Data.OracleClient.Oci;
21
22 namespace System.Data.OracleClient
23 {
24         public sealed class OracleTransaction :
25 #if NET_2_0
26         Common.DbTransaction
27 #else
28         MarshalByRefObject, IDbTransaction, IDisposable
29 #endif
30         {
31                 #region Fields
32
33                 OracleConnection connection;
34                 IsolationLevel isolationLevel;
35                 bool disposed = false;
36                 OciTransactionHandle transaction;
37                 bool isOpen;
38
39                 #endregion // Fields
40
41                 #region Constructors
42
43                 internal OracleTransaction (OracleConnection connection, IsolationLevel isolevel, OciTransactionHandle transaction)
44                 {
45                         this.connection = connection;
46                         this.isolationLevel = isolevel;
47                         this.transaction = transaction;
48                         isOpen = true;
49                 }
50
51                 #endregion // Constructors
52
53                 #region Properties
54
55                 internal bool IsOpen {
56                         get { return isOpen; }
57                 }
58
59                 public
60 #if NET_2_0
61                 new
62 #endif
63                 OracleConnection Connection {
64                         get { return connection; }
65                 }
66                 
67 #if NET_2_0
68                 [MonoTODO]
69                 protected override Common.DbConnection DbConnection {
70                         get { return Connection; }
71                 }
72 #endif
73
74                 public
75 #if NET_2_0
76                 override
77 #endif
78                 IsolationLevel IsolationLevel {
79                         get { return isolationLevel; }
80                 }
81
82 #if !NET_2_0
83                 IDbConnection IDbTransaction.Connection {
84                         get { return Connection; }
85                 }
86 #endif
87
88                 #endregion // Properties
89
90                 #region Methods
91
92                 internal void AttachToServiceContext ()
93                 {
94                         transaction.AttachToServiceContext ();
95                 }
96
97                 public
98 #if NET_2_0
99                 override
100 #endif
101                 void Commit ()
102                 {
103                         transaction.Commit ();
104                         Connection.Transaction = null;
105                         isOpen = false;
106                 }
107
108 #if NET_2_0
109                 protected override
110 #endif
111                 void Dispose (bool disposing)
112                 {
113                         if (!disposed) {
114                                 if (disposing) {
115                                         if (isOpen)
116                                                 Rollback ();
117
118                                         transaction.Dispose();
119                                 }
120                                 disposed = true;
121                         }
122                 }
123
124 #if !NET_2_0
125                 public void Dispose ()
126                 {
127                         Dispose (true);
128                         GC.SuppressFinalize (this);
129                 }
130 #endif
131
132                 public
133 #if NET_2_0
134                 override
135 #endif
136                 void Rollback ()
137                 {
138                         transaction.Rollback ();
139                         Connection.Transaction = null;
140                         isOpen = false;
141                 }
142
143                 #endregion // Methods
144         }
145 }