2007-04-18 Jeffrey Stedfast <fejj@novell.com>
[mono.git] / mcs / class / System.Data / System.Data.ProviderBase / DbConnectionBase.cs
1 //
2 // System.Data.ProviderBase.DbConnectionBase
3 //
4 // Author:
5 //   Tim Coleman (tim@timcoleman.com)
6 //
7 // Copyright (C) Tim Coleman, 2003
8 //
9
10 //
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32
33 #if NET_2_0
34 using System.Transactions;
35 using System.Data.Common;
36 using System.EnterpriseServices;
37
38 namespace System.Data.ProviderBase {
39         public abstract class DbConnectionBase : DbConnection
40         {
41                 #region Fields
42
43                 DbConnectionFactory connectionFactory;
44                 DbConnectionString connectionOptions;
45                 string connectionString;
46                 bool disposed = false;
47                 
48                 #endregion // Fields
49
50                 #region Constructors
51
52                 protected DbConnectionBase (DbConnectionBase connection)
53                         : this (connection.ConnectionFactory)
54                 {
55                 }
56
57                 protected DbConnectionBase (DbConnectionFactory connectionFactory)
58                 {
59                         this.connectionFactory = connectionFactory;
60                 }
61
62                 protected DbConnectionBase ()
63                 {
64                         
65                 }
66                 
67                 #endregion // Constructors
68
69                 #region Properties
70
71                 [MonoTODO]
72                 protected int CloseCount {
73                         get { throw new NotImplementedException (); }
74                 }
75
76                 protected internal DbConnectionFactory ConnectionFactory {
77                         get { return connectionFactory; }
78                 }
79
80                 protected internal DbConnectionString ConnectionOptions {
81                         get { return connectionOptions; }
82                 }
83
84                 public override string ConnectionString {
85                         get { return connectionString; }
86                         set { 
87                                 //connectionOptions = ConnectionFactory.CreateConnectionOptionsInternal (value);
88                                 connectionString = value;
89                         }
90                 }
91
92                 [MonoTODO]
93                 public override int ConnectionTimeout {
94                         get { throw new NotImplementedException (); }
95                 }
96
97                 [MonoTODO]
98                 protected virtual int ConnectionTimeoutInternal {
99                         get { throw new NotImplementedException (); }
100                 }
101
102                 [MonoTODO]
103                 public override string Database {
104                         get { throw new NotImplementedException (); }
105                 }
106
107                 [MonoTODO]
108                 public override string DataSource {
109                         get { throw new NotImplementedException (); }
110                 }
111
112                 [MonoTODO]
113                 protected internal DbConnectionInternal InnerConnection {
114                         get { throw new NotImplementedException (); }
115                 }
116
117                 [MonoTODO]
118                 public override string ServerVersion {
119                         get { throw new NotImplementedException (); }
120                 }
121
122                 [MonoTODO]
123                 public override ConnectionState State {
124                         get { throw new NotImplementedException (); }
125                 }
126
127                 #endregion // Properties
128
129                 #region Events
130
131                 public event StateChangeEventHandler StateChange;
132
133                 #endregion // Events
134
135                 #region Methods
136
137                 [MonoTODO]
138                 protected override DbTransaction BeginDbTransaction (IsolationLevel isolationLevel)
139                 {
140                         throw new NotImplementedException ();
141                 }
142
143                 [MonoTODO]
144                 public override void ChangeDatabase (string value)
145                 {
146                         throw new NotImplementedException ();
147                 }
148
149                 [MonoTODO]
150                 public override void Close ()
151                 {
152                         throw new NotImplementedException ();
153                 }
154
155                 protected override DbCommand CreateDbCommand ()
156                 {
157                         DbCommand cmd = (DbCommand) ConnectionFactory.ProviderFactory.CreateCommand ();
158                         cmd.Connection = this;
159                         return cmd;
160                 }
161
162                 protected override void Dispose (bool disposing)
163                 {
164                         if (!disposed) { 
165                                 try {
166                                         if (disposing) {
167                                                 // do necessary clean up
168                                         }
169                                         disposed = true;
170                                 } finally {
171                                         base.Dispose (disposing);
172                                 }
173                         }
174                 }
175
176                 [MonoTODO]
177                 public void EnlistDistributedTransaction (EnterpriseServices.ITransaction transaction)
178                 {
179                         throw new NotImplementedException ();
180                 }
181
182                 [MonoTODO]
183                 public void EnlistTransaction (Transaction transaction)
184                 {
185                         throw new NotImplementedException ();                        
186                 }
187
188                 [MonoTODO]
189                 protected virtual DbMetaDataFactory GetMetaDataFactory (DbConnectionInternal internalConnection)
190                 {
191                         throw new NotImplementedException ();
192                 }
193
194                 protected void OnStateChange (ConnectionState originalState, ConnectionState currentState)
195                 {
196                         if (StateChange != null)
197                                 StateChange (this, new StateChangeEventArgs (originalState, currentState));
198                 }
199
200                 [MonoTODO]
201                 public override void Open ()
202                 {
203                         throw new NotImplementedException ();
204                 }
205
206                 [MonoTODO]
207                 public override DataTable GetSchema ()
208                 {
209                         throw new NotImplementedException ();
210                 }
211
212                 [MonoTODO]
213                 public override DataTable GetSchema (string collectionName)
214                 {
215                         throw new NotImplementedException ();
216                 }
217
218                 [MonoTODO]
219                 public override DataTable GetSchema (string collectionName, string [] restrictionValues)
220                 {
221                         throw new NotImplementedException ();
222                 }
223
224                 #endregion // Methods
225         }
226 }
227
228 #endif