Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Moved deprecated library

svn path=/old-code/; revision=152781
  • Loading branch information...
commit 9c3b69d21a37e815053bdf167e94f4e2b14df73d 1 parent a6dabbb
Miguel de Icaza authored March 02, 2010
31  Mono.Data/AssemblyInfo.cs
... ...
@@ -0,0 +1,31 @@
  1
+//
  2
+// AssemblyInfo.cs
  3
+//
  4
+// Author:
  5
+//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
  6
+//
  7
+// (C) 2003 Ximian, Inc.  http://www.ximian.com
  8
+// (C) 2004 Novell (http://www.novell.com)
  9
+//
  10
+
  11
+using System;
  12
+using System.Reflection;
  13
+using System.Runtime.InteropServices;
  14
+
  15
+[assembly: AssemblyVersion (Consts.FxVersion)]
  16
+
  17
+/* TODO COMPLETE INFORMATION
  18
+
  19
+[assembly: AssemblyTitle ("")]
  20
+[assembly: AssemblyDescription ("")]
  21
+
  22
+[assembly: CLSCompliant (true)]
  23
+[assembly: AssemblyFileVersion ("0.0.0.1")]
  24
+
  25
+[assembly: ComVisible (false)]
  26
+
  27
+*/
  28
+
  29
+[assembly: AssemblyDelaySign (true)]
  30
+[assembly: AssemblyKeyFile ("../mono.pub")]
  31
+
61  Mono.Data/ChangeLog
... ...
@@ -0,0 +1,61 @@
  1
+2008-12-30  Gert Driesen  <drieseng@users.sourceforge.net>
  2
+
  3
+	* DataTools.cs
  4
+	* Provider.cs
  5
+	* ProviderCollection.cs
  6
+	* ProviderFactory.cs: Fixed line endings.
  7
+
  8
+2008-09-06  Daniel Morgan <monodanmorg@yahoo.com>
  9
+
  10
+	* ProviderSectionHandler.cs
  11
+	* ProviderFactory.cs
  12
+	* ProviderCollection.cs
  13
+	* DataTools.cs
  14
+	* Provider.cs: for the NET_2_0 profile, 
  15
+	added Obsolete attribute
  16
+	to all classes in assembly Mono.Data because it
  17
+	has been superceded by DbProviderFactories in System.Data
  18
+
  19
+2006-02-13  Daniel Morgan <danielmorgan@verizon.net>
  20
+	
  21
+	* ProviderSectionHandler.cs
  22
+	* Provider.cs: add support 
  23
+	for parameter prefix and command builder
  24
+	
  25
+	* app.config: updated the sample app.config file
  26
+	to include parameterprefix and commandbuilder on
  27
+	some providers
  28
+
  29
+2006-02-13  Daniel Morgan <danielmorgan@verizon.net>
  30
+
  31
+	Patches from Brad Langhorst <brad@langhorst.com>
  32
+	
  33
+	* ProviderSectionHandler.cs
  34
+	* ProviderFactory
  35
+	* ProviderCollection.cs
  36
+	* DataTools.cs
  37
+	* Provider.cs: catch invalid args, 
  38
+	allow non-qualified assembly loading, 
  39
+	warn about empty providers
  40
+	
  41
+2005-12-31  Daniel Morgan <danielmorgan@verizon.net>
  42
+
  43
+	* test/test.exe.config	
  44
+	* app.config: add new ADO.NET providers, remove obsolete providers, and
  45
+	add more sample connection strings
  46
+	
  47
+	* Provider.cs: load providers internal to System.Data differently than those
  48
+	that are external, better error handling for assembly or connection class not found
  49
+
  50
+2004-03-30  Lluis Sanchez Gual  <lluis@ximian.com>
  51
+
  52
+	* DataTools.cs: in FillDataSet(string,SelectCommand), use the connection
  53
+	got from the configuration file to create the data adapter. Patch by
  54
+	Matthijs ter Woord.
  55
+
  56
+2003-12-15  Gonzalo Paniagua Javier <gonzalo@ximian.com>
  57
+
  58
+	* ProviderSectionHandler.cs: use XPath to get the providers to avoid
  59
+	getting an exception when there's whitespace, comments... Patch by Marco
  60
+	Canini <marco.canini@fastwebnet.it>.
  61
+
133  Mono.Data/DataTools.cs
... ...
@@ -0,0 +1,133 @@
  1
+//
  2
+// Mono.Data.DataTools
  3
+//
  4
+// Authors:
  5
+//   Brian Ritchie (brianlritchie@hotmail.com) 
  6
+//  
  7
+//
  8
+// Copyright (C) Brian Ritchie, 2002
  9
+// 
  10
+//
  11
+
  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
+using System;
  33
+using System.Data;
  34
+
  35
+namespace Mono.Data
  36
+{
  37
+	/// <summary>
  38
+	/// Summary description for ProviderTools.
  39
+	/// </summary>
  40
+#if NET_2_0
  41
+	[Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")]
  42
+#endif
  43
+	public class DataTools
  44
+	{
  45
+		public DataTools()
  46
+		{
  47
+		}
  48
+
  49
+		static public IDataParameter AddParameter(IDbCommand Cmd, string ParameterName, DbType DbType, 
  50
+			ParameterDirection Direction)
  51
+		{
  52
+			if (Cmd == null) 
  53
+				throw new System.ArgumentNullException ("Cmd");
  54
+			if (ParameterName == null) 
  55
+				throw new System.ArgumentNullException ("ParameterName");
  56
+
  57
+			IDataParameter param = Cmd.CreateParameter ();
  58
+			Cmd.Parameters.Add (param);
  59
+			param.ParameterName = ParameterName;
  60
+			param.Direction = Direction;
  61
+			param.DbType = DbType;
  62
+			return param;
  63
+		}
  64
+
  65
+		static public IDataParameter AddParameter(IDbCommand Cmd, string ParameterName, DbType DbType)
  66
+		{
  67
+			if (Cmd == null) 
  68
+				throw new System.ArgumentNullException ("Cmd");
  69
+			if (ParameterName == null) 
  70
+				throw new System.ArgumentNullException("ParameterName");
  71
+
  72
+			IDataParameter param = Cmd.CreateParameter ();
  73
+			Cmd.Parameters.Add (param);
  74
+			param.ParameterName = ParameterName;
  75
+			param.DbType = DbType;
  76
+			return param;
  77
+		}
  78
+
  79
+		static public DataSet FillDataSet (IDbConnection conn, string SelectCommand)
  80
+		{
  81
+			if (conn == null) 
  82
+				throw new System.ArgumentNullException ("conn");
  83
+			if (SelectCommand == null) 
  84
+				throw new System.ArgumentNullException ("SelectCommand");
  85
+
  86
+			DataSet ds = new DataSet ();
  87
+			IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (conn, SelectCommand);
  88
+			if (conn.State != ConnectionState.Open)
  89
+				conn.Open ();
  90
+			adapter.Fill (ds);
  91
+			return ds;
  92
+		}
  93
+
  94
+		static public DataSet FillDataSet(IDbCommand SelectCommand)
  95
+		{
  96
+			if (SelectCommand == null) 
  97
+				throw new System.ArgumentNullException ("SelectCommand");
  98
+
  99
+			DataSet ds = new DataSet ();
  100
+			IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (SelectCommand);
  101
+			if (adapter.SelectCommand.Connection.State != ConnectionState.Open)
  102
+				adapter.SelectCommand.Connection.Open ();
  103
+			adapter.Fill (ds);
  104
+			return ds;
  105
+		}
  106
+
  107
+		static public DataSet FillDataSet(string ConfigSetting, string SelectCommand)
  108
+		{
  109
+			if (ConfigSetting == null) 
  110
+				throw new System.ArgumentNullException ("ConfigSetting");
  111
+			if (SelectCommand == null) 
  112
+				throw new System.ArgumentNullException ("SelectCommand");
  113
+
  114
+			IDbConnection conn = ProviderFactory.CreateConnectionFromConfig (ConfigSetting);
  115
+			conn.Open ();
  116
+			DataSet ds = null;
  117
+			try
  118
+			{
  119
+				ds = new DataSet ();
  120
+				IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (conn, SelectCommand);
  121
+				adapter.Fill (ds);
  122
+			}
  123
+			finally
  124
+			{
  125
+				conn.Close ();
  126
+			}
  127
+			return ds;
  128
+		}
  129
+
  130
+
  131
+	}
  132
+}
  133
+
10  Mono.Data/Makefile
... ...
@@ -0,0 +1,10 @@
  1
+thisdir = class/Mono.Data
  2
+SUBDIRS =
  3
+include ../../build/rules.make
  4
+
  5
+LIBRARY = Mono.Data.dll
  6
+LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:System.Xml.dll \
  7
+    /r:System.Data.dll
  8
+NO_TEST = yes
  9
+
  10
+include ../../build/library.make
7  Mono.Data/Mono.Data.dll.sources
... ...
@@ -0,0 +1,7 @@
  1
+AssemblyInfo.cs
  2
+../../build/common/Consts.cs
  3
+DataTools.cs
  4
+Provider.cs
  5
+ProviderCollection.cs
  6
+ProviderFactory.cs
  7
+ProviderSectionHandler.cs
268  Mono.Data/Provider.cs
... ...
@@ -0,0 +1,268 @@
  1
+//
  2
+// Mono.Data.Provider
  3
+//
  4
+// Authors:
  5
+//   Brian Ritchie (brianlritchie@hotmail.com) 
  6
+//  
  7
+//
  8
+// Copyright (C) Brian Ritchie, 2002
  9
+// 
  10
+//
  11
+
  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
+using System;
  33
+using System.Data;
  34
+using System.Reflection;
  35
+using System.IO;
  36
+
  37
+namespace Mono.Data
  38
+{
  39
+#if NET_2_0
  40
+	[Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")]
  41
+#endif
  42
+	public class Provider
  43
+	{
  44
+		private string name = null;
  45
+		private string connectionTypeName;
  46
+		private string adapterTypeName;
  47
+		private string commandTypeName;
  48
+		private Type connectionType;
  49
+		private Type adapterType;
  50
+		private Type commandType;
  51
+		private Assembly providerAssembly;
  52
+		private string assemblyName;
  53
+		private string description;
  54
+		private string parameterprefix;
  55
+		private string commandBuilderTypeName = String.Empty;
  56
+		private Type commandBuilderType;
  57
+
  58
+		public Provider(string _name, string _connection, 
  59
+			string _dataadapter, string _command, string _assembly,
  60
+			string _description) 
  61
+		{
  62
+			name = _name;
  63
+			connectionTypeName = _connection;
  64
+			adapterTypeName = _dataadapter;
  65
+			assemblyName = _assembly;
  66
+			commandTypeName = _command;
  67
+			description = _description;
  68
+		}
  69
+
  70
+		public Provider(string _name, string _connection, 
  71
+			string _dataadapter, string _command, string _assembly,
  72
+			string _description, string _parameterprefix, string _commandbuilder)
  73
+		{
  74
+			name = _name;
  75
+			connectionTypeName = _connection;
  76
+			adapterTypeName = _dataadapter;
  77
+			assemblyName = _assembly;
  78
+			commandTypeName = _command;
  79
+			description = _description;
  80
+
  81
+			switch(_parameterprefix) {
  82
+			case "colon":
  83
+				parameterprefix = ":"; // named parameter prefixed by a semicolon
  84
+				break;
  85
+			case "at":
  86
+				parameterprefix = "@"; // named parameter prefixed by an at symbol
  87
+				break;
  88
+			case "questionmark":
  89
+				parameterprefix = "?"; // postional parameter noted by the question mark
  90
+				break;
  91
+			}
  92
+
  93
+			commandBuilderTypeName = _commandbuilder;
  94
+		}
  95
+
  96
+		public Provider(string _name, Type _connection, Type _dataadapter, Type _command,
  97
+			string _description)
  98
+		{
  99
+			if (_connection == null) 
  100
+				throw new System.ArgumentNullException ("_connection");
  101
+			if (_dataadapter == null) 
  102
+				throw new System.ArgumentNullException ("_dataadapter");
  103
+			if (_command == null) 
  104
+				throw new System.ArgumentNullException ("_command");
  105
+
  106
+			name = _name;
  107
+			connectionTypeName = _connection.FullName;
  108
+			adapterTypeName = _dataadapter.FullName;
  109
+			commandTypeName = _command.FullName;
  110
+			connectionType = _connection;
  111
+			adapterType = _dataadapter;
  112
+			commandType = _command;
  113
+			description = _description;
  114
+		}
  115
+
  116
+		public string Name
  117
+		{
  118
+			get {return name;}
  119
+		}
  120
+
  121
+		public string Description
  122
+		{
  123
+			get {return description;}
  124
+		}
  125
+
  126
+		public string ParameterPrefix 
  127
+		{
  128
+			get {return parameterprefix;}
  129
+		}
  130
+
  131
+		public Assembly ProviderAssembly {
  132
+			get {
  133
+				if (providerAssembly == null) {
  134
+					if (assemblyName.IndexOf(',') == -1) //try to load with a partial name if that's all we have
  135
+						providerAssembly = Assembly.LoadWithPartialName (assemblyName);
  136
+					else 
  137
+						providerAssembly = Assembly.Load (assemblyName);
  138
+				}
  139
+
  140
+				return providerAssembly;
  141
+			}
  142
+		}
  143
+
  144
+		public Type ConnectionType
  145
+		{
  146
+			get {
  147
+				if (connectionType == null) {
  148
+					connectionType = ProviderAssembly.GetType (connectionTypeName, false);
  149
+					if (connectionType == null) {
  150
+						throw new Exception (String.Format ("Unable to load type of connection class: {0} from assembly: {1}",
  151
+							connectionTypeName, assemblyName));
  152
+					}
  153
+				}
  154
+				return connectionType;
  155
+			}
  156
+		}
  157
+
  158
+		public Type DataAdapterType
  159
+		{
  160
+			get {
  161
+				if (adapterType == null) {
  162
+					adapterType = ProviderAssembly.GetType (adapterTypeName, false);
  163
+					if (adapterType == null) {
  164
+						throw new Exception (String.Format ("Unable to load type of adapter class: {0} from assembly: {1}",
  165
+							adapterTypeName, assemblyName));
  166
+					}
  167
+				}
  168
+				return adapterType;
  169
+			}
  170
+		}
  171
+
  172
+		public Type CommandType {
  173
+			get {
  174
+				if (commandType == null) {
  175
+					commandType = ProviderAssembly.GetType (commandTypeName, false);
  176
+					if (commandType == null) {
  177
+						throw new Exception (String.Format ("Unable to load type of command class: {0} from assembly: {1}",
  178
+							commandTypeName, assemblyName));
  179
+					}
  180
+				}
  181
+				return commandType;
  182
+			}
  183
+		}
  184
+
  185
+		public Type CommandBuilderType {
  186
+			get {
  187
+				if (commandBuilderType == null) {
  188
+					if (commandBuilderTypeName.Equals(String.Empty))
  189
+						throw new Exception("Provider does not have CommandBuilder type defined.");
  190
+					commandBuilderType = ProviderAssembly.GetType (commandBuilderTypeName, false);
  191
+					if (commandBuilderType == null) {
  192
+						throw new Exception (String.Format ("Unable to load type of command class: {0} from assembly: {1}",
  193
+							commandBuilderTypeName, assemblyName));
  194
+					}
  195
+				}
  196
+				return commandBuilderType;
  197
+			}
  198
+		}
  199
+
  200
+		public IDbConnection CreateConnection()
  201
+		{
  202
+			object connObj = null;
  203
+
  204
+			switch (Name) {
  205
+			case "System.Data.SqlClient":
  206
+				connObj = new System.Data.SqlClient.SqlConnection ();
  207
+				break;
  208
+			case "System.Data.Odbc":
  209
+				connObj = new System.Data.Odbc.OdbcConnection ();
  210
+				break;
  211
+			case "System.Data.OleDb":
  212
+				connObj = new System.Data.OleDb.OleDbConnection ();
  213
+				break;
  214
+			default:
  215
+				connObj = Activator.CreateInstance (ConnectionType);
  216
+				break;
  217
+			}
  218
+
  219
+			if (connObj == null)
  220
+				throw new Exception (String.Format ("Unable to create instance of connection class: {0} from assembly: {1}",
  221
+					connectionTypeName, assemblyName));
  222
+			
  223
+			return (IDbConnection) connObj;
  224
+		}
  225
+
  226
+		public IDbDataAdapter CreateDataAdapter()
  227
+		{
  228
+			object adapterObj = Activator.CreateInstance (DataAdapterType);
  229
+			if (adapterObj == null)
  230
+				throw new Exception (String.Format ("Unable to create instance of adapter class: {0} from assembly: {1}",
  231
+					adapterTypeName, assemblyName));
  232
+
  233
+			return (IDbDataAdapter) adapterObj;
  234
+		}
  235
+
  236
+		public IDbCommand CreateCommand()
  237
+		{
  238
+			object commandObj = Activator.CreateInstance (CommandType);
  239
+			if (commandObj == null)
  240
+				throw new Exception (String.Format ("Unable to create instance of command class: {0} from assembly: {1}",
  241
+					commandTypeName, assemblyName));
  242
+
  243
+			return (IDbCommand) commandObj;
  244
+		}
  245
+
  246
+		public object CreateCommandBuilder(IDbDataAdapter adapter) 
  247
+		{
  248
+			if (adapter == null) 
  249
+				throw new System.ArgumentNullException ("adapter");
  250
+
  251
+			object obj = (object) adapter;
  252
+			if (!DataAdapterType.ToString ().Equals (obj.ToString ()))
  253
+				throw new System.ArgumentException ("adapter not part of this provider.");
  254
+				
  255
+			if (commandBuilderTypeName.Equals (String.Empty))
  256
+				throw new Exception ("Provider does not have CommandBuilder type defined.");
  257
+			
  258
+			object[] parms = new object [] { obj };
  259
+			object commandBuilderObj = Activator.CreateInstance (CommandBuilderType, parms);
  260
+			if (commandBuilderObj == null)
  261
+				throw new Exception (String.Format ("Unable to create instance of command builder class: {0} from assembly: {1}",
  262
+					commandBuilderTypeName, assemblyName));
  263
+
  264
+			return commandBuilderObj;
  265
+		}
  266
+	}
  267
+}
  268
+
323  Mono.Data/ProviderCollection.cs
... ...
@@ -0,0 +1,323 @@
  1
+//
  2
+// Mono.Data.ProviderCollection
  3
+//
  4
+// Authors:
  5
+//   Brian Ritchie (brianlritchie@hotmail.com) 
  6
+//  
  7
+//
  8
+// Copyright (C) Brian Ritchie, 2002
  9
+// 
  10
+//
  11
+
  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
+namespace Mono.Data 
  33
+{
  34
+	using System;
  35
+	using System.Collections;
  36
+	using System.Collections.Specialized;
  37
+	
  38
+	
  39
+	/// <summary>
  40
+	///     <para>
  41
+	///       A collection that stores <see cref='.Provider'/> objects.
  42
+	///    </para>
  43
+	/// </summary>
  44
+	/// <seealso cref='.ProviderCollection'/>
  45
+	[Serializable ()]
  46
+#if NET_2_0
  47
+	[Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")]
  48
+#endif
  49
+	public class ProviderCollection : DictionaryBase  
  50
+	{
  51
+		
  52
+		/// <summary>
  53
+		///     <para>
  54
+		///       Initializes a new instance of <see cref='.ProviderCollection'/>.
  55
+		///    </para>
  56
+		/// </summary>
  57
+		public ProviderCollection ()
  58
+
  59
+		{
  60
+		}
  61
+		
  62
+		/// <summary>
  63
+		///     <para>
  64
+		///       Initializes a new instance of <see cref='.ProviderCollection'/> based on another <see cref='.ProviderCollection'/>.
  65
+		///    </para>
  66
+		/// </summary>
  67
+		/// <param name='value'>
  68
+		///       A <see cref='.ProviderCollection'/> from which the contents are copied
  69
+		/// </param>
  70
+		public ProviderCollection (ProviderCollection value) 
  71
+		{
  72
+			if (value == null) 
  73
+				throw new System.ArgumentNullException ("value");
  74
+
  75
+			this.AddRange (value);
  76
+		}
  77
+		
  78
+		/// <summary>
  79
+		///     <para>
  80
+		///       Initializes a new instance of <see cref='.ProviderCollection'/> containing any array of <see cref='.Provider'/> objects.
  81
+		///    </para>
  82
+		/// </summary>
  83
+		/// <param name='value'>
  84
+		///       A array of <see cref='.Provider'/> objects with which to intialize the collection
  85
+		/// </param>
  86
+		public ProviderCollection (Provider[] value) 
  87
+		{
  88
+			if (value == null) 
  89
+				throw new System.ArgumentNullException ("value");
  90
+
  91
+			this.AddRange (value);
  92
+		}
  93
+		
  94
+		/// <summary>
  95
+		/// <para>Represents the entry at the specified index of the <see cref='.Provider'/>.</para>
  96
+		/// </summary>
  97
+		/// <param name='index'><para>The zero-based index of the entry to locate in the collection.</para></param>
  98
+		/// <value>
  99
+		///    <para> The entry at the specified index of the collection.</para>
  100
+		/// </value>
  101
+		/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
  102
+		public Provider this [string Name] 
  103
+		{
  104
+			get {				
  105
+				return ((Provider)(Dictionary [Name]));
  106
+			}
  107
+			set {
  108
+				Dictionary [Name] = value;
  109
+			}
  110
+		}
  111
+
  112
+		public Provider FindByCommandType(Type CommandType)
  113
+		{
  114
+			if (CommandType == null) 
  115
+				throw new System.ArgumentNullException ("CommandType");
  116
+
  117
+			foreach (Provider p in this) {
  118
+				if (p.CommandType == CommandType)
  119
+					return p;
  120
+			}
  121
+			throw new IndexOutOfRangeException ();
  122
+		}
  123
+
  124
+		public Provider FindByDataAdapterType(Type DataAdapterType)
  125
+		{
  126
+			if (DataAdapterType == null) 
  127
+				throw new System.ArgumentNullException ("DataAdapterType");
  128
+
  129
+			foreach (Provider p in this) {
  130
+				if (p.DataAdapterType == DataAdapterType)
  131
+					return p;
  132
+			}
  133
+			throw new IndexOutOfRangeException ();
  134
+		}
  135
+
  136
+		public Provider FindByConnectionType(Type ConnectionType)
  137
+		{
  138
+			if (ConnectionType == null) 
  139
+				throw new System.ArgumentNullException("ConnectionType");
  140
+
  141
+			foreach (Provider p in this) {
  142
+				if (p.ConnectionType == ConnectionType)
  143
+					return p;
  144
+			}
  145
+			throw new IndexOutOfRangeException ();
  146
+		}
  147
+
  148
+		/// <summary>
  149
+		///    <para>Adds a <see cref='.Provider'/> with the specified value to the 
  150
+		///    <see cref='.ProviderCollection'/> .</para>
  151
+		/// </summary>
  152
+		/// <param name='value'>The <see cref='.Provider'/> to add.</param>
  153
+		/// <returns>
  154
+		///    <para>The index at which the new element was inserted.</para>
  155
+		/// </returns>
  156
+		/// <seealso cref='.ProviderCollection.AddRange'/>
  157
+		public void Add(Provider value) 
  158
+		{
  159
+			if (value == null) 
  160
+				throw new System.ArgumentNullException ("value");
  161
+
  162
+			Dictionary.Add (value.Name, value);
  163
+		}
  164
+		
  165
+		/// <summary>
  166
+		/// <para>Copies the elements of an array to the end of the <see cref='.ProviderCollection'/>.</para>
  167
+		/// </summary>
  168
+		/// <param name='value'>
  169
+		///    An array of type <see cref='.Provider'/> containing the objects to add to the collection.
  170
+		/// </param>
  171
+		/// <returns>
  172
+		///   <para>None.</para>
  173
+		/// </returns>
  174
+		/// <seealso cref='.ProviderCollection.Add'/>
  175
+		public void AddRange (Provider[] value) 
  176
+		{
  177
+			if (value == null) 
  178
+				throw new System.ArgumentNullException ("value");
  179
+
  180
+			for (int i = 0; i < value.Length; i++) 
  181
+				this.Add (value [i]);
  182
+		}
  183
+		
  184
+		/// <summary>
  185
+		///     <para>
  186
+		///       Adds the contents of another <see cref='.ProviderCollection'/> to the end of the collection.
  187
+		///    </para>
  188
+		/// </summary>
  189
+		/// <param name='value'>
  190
+		///    A <see cref='.ProviderCollection'/> containing the objects to add to the collection.
  191
+		/// </param>
  192
+		/// <returns>
  193
+		///   <para>None.</para>
  194
+		/// </returns>
  195
+		/// <seealso cref='.ProviderCollection.Add'/>
  196
+		public void AddRange(ProviderCollection value) 
  197
+		{
  198
+			if (value == null) 
  199
+				throw new System.ArgumentNullException ("value");
  200
+
  201
+			foreach (Provider p in value)
  202
+				this.Add (p);
  203
+		}
  204
+		
  205
+		/// <summary>
  206
+		/// <para>Gets a value indicating whether the 
  207
+		///    <see cref='.ProviderCollection'/> contains the specified <see cref='.Provider'/>.</para>
  208
+		/// </summary>
  209
+		/// <param name='value'>The <see cref='.Provider'/> to locate.</param>
  210
+		/// <returns>
  211
+		/// <para><see langword='true'/> if the <see cref='.Provider'/> is contained in the collection; 
  212
+		///   otherwise, <see langword='false'/>.</para>
  213
+		/// </returns>
  214
+		/// <seealso cref='.ProviderCollection.IndexOf'/>
  215
+		public bool Contains (Provider value) 
  216
+		{
  217
+			if (value == null) 
  218
+				throw new System.ArgumentNullException("value");
  219
+
  220
+			return Dictionary.Contains (value);
  221
+		}
  222
+		
  223
+		/// <summary>
  224
+		/// <para>Copies the <see cref='.ProviderCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the 
  225
+		///    specified index.</para>
  226
+		/// </summary>
  227
+		/// <param name='array'><para>The one-dimensional <see cref='System.Array'/> that is the destination of the values copied from <see cref='.ProviderCollection'/> .</para></param>
  228
+		/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
  229
+		/// <returns>
  230
+		///   <para>None.</para>
  231
+		/// </returns>
  232
+		/// <exception cref='System.ArgumentException'><para><paramref name='array'/> is multidimensional.</para> <para>-or-</para> <para>The number of elements in the <see cref='.ProviderCollection'/> is greater than the available space between <paramref name='arrayIndex'/> and the end of <paramref name='array'/>.</para></exception>
  233
+		/// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
  234
+		/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
  235
+		/// <seealso cref='System.Array'/>
  236
+		public void CopyTo(Provider[] array, int index) 
  237
+		{
  238
+			if (array == null) 
  239
+				throw new System.ArgumentNullException ("array");
  240
+
  241
+			Dictionary.CopyTo(array, index);
  242
+		}
  243
+		
  244
+		/// <summary>
  245
+		///    <para>Returns an enumerator that can iterate through 
  246
+		///       the <see cref='.ProviderCollection'/> .</para>
  247
+		/// </summary>
  248
+		/// <returns><para>None.</para></returns>
  249
+		/// <seealso cref='System.Collections.IEnumerator'/>
  250
+		public new ProviderEnumerator GetEnumerator () 
  251
+		{
  252
+			return new ProviderEnumerator (this);
  253
+		}
  254
+		
  255
+		/// <summary>
  256
+		///    <para> Removes a specific <see cref='.Provider'/> from the 
  257
+		///    <see cref='.ProviderCollection'/> .</para>
  258
+		/// </summary>
  259
+		/// <param name='value'>The <see cref='.Provider'/> to remove from the <see cref='.ProviderCollection'/> .</param>
  260
+		/// <returns><para>None.</para></returns>
  261
+		/// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
  262
+		public void Remove(Provider value) 
  263
+		{
  264
+			if (value == null) 
  265
+				throw new System.ArgumentNullException ("value");
  266
+
  267
+			Dictionary.Remove(value);
  268
+		}
  269
+		
  270
+		public class ProviderEnumerator : object, IEnumerator 
  271
+		{
  272
+			
  273
+			private IEnumerator baseEnumerator;
  274
+			
  275
+			private IEnumerable temp;
  276
+			
  277
+			public ProviderEnumerator(ProviderCollection mappings) 
  278
+			{
  279
+				if (mappings == null) 
  280
+					throw new System.ArgumentNullException ("mappings");
  281
+
  282
+				this.temp = ((IEnumerable)(mappings));
  283
+				this.baseEnumerator = temp.GetEnumerator();
  284
+			}
  285
+			
  286
+			public Provider Current 
  287
+			{
  288
+				get 
  289
+				{
  290
+					return ((Provider) ((DictionaryEntry) (baseEnumerator.Current)).Value);
  291
+				}
  292
+			}
  293
+			
  294
+			object IEnumerator.Current 
  295
+			{
  296
+				get 
  297
+				{
  298
+					return baseEnumerator.Current;
  299
+				}
  300
+			}
  301
+			
  302
+			public bool MoveNext() 
  303
+			{
  304
+				return baseEnumerator.MoveNext();
  305
+			}
  306
+			
  307
+			bool IEnumerator.MoveNext() 
  308
+			{
  309
+				return baseEnumerator.MoveNext();
  310
+			}
  311
+			
  312
+			public void Reset() 
  313
+			{
  314
+				baseEnumerator.Reset();
  315
+			}
  316
+			
  317
+			void IEnumerator.Reset() 
  318
+			{
  319
+				baseEnumerator.Reset();
  320
+			}
  321
+		}
  322
+	}
  323
+}
178  Mono.Data/ProviderFactory.cs
... ...
@@ -0,0 +1,178 @@
  1
+//
  2
+// Mono.Data.ProviderFactory
  3
+//
  4
+// Authors:
  5
+//   Brian Ritchie (brianlritchie@hotmail.com) 
  6
+//  
  7
+//
  8
+// Copyright (C) Brian Ritchie, 2002
  9
+// 
  10
+//
  11
+
  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
+using System;
  33
+using System.Data;
  34
+using System.Reflection;
  35
+using System.Runtime.Remoting;
  36
+using System.Configuration;
  37
+using System.Xml;
  38
+using System.Collections.Specialized;
  39
+
  40
+namespace Mono.Data
  41
+{
  42
+#if NET_2_0
  43
+	[Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")]
  44
+#endif
  45
+	public class ProviderFactory
  46
+	{
  47
+		private static ProviderCollection providers;
  48
+
  49
+		static ProviderFactory ()
  50
+		{
  51
+			providers = (ProviderCollection) ConfigurationSettings.GetConfig ("mono.data/providers");
  52
+			if (providers == null) {
  53
+				providers = new ProviderCollection ();
  54
+				// warn the developer or administrator that the provider list is empty
  55
+				System.Diagnostics.Debug.Listeners.Add (new System.Diagnostics.TextWriterTraceListener (Console.Out));
  56
+				System.Diagnostics.Debug.WriteLine ("No providers found. Did you set up a mono.data/providers area in your app.config or in machine.config?");
  57
+			}
  58
+
  59
+		}
  60
+
  61
+		static public ProviderCollection Providers
  62
+		{
  63
+			get {
  64
+				return providers;
  65
+			}
  66
+		}
  67
+
  68
+		static public IDbConnection CreateConnectionFromConfig (string Setting)
  69
+		{
  70
+			if (Setting == null) 
  71
+				throw new System.ArgumentNullException ("Setting");
  72
+
  73
+			return CreateConnection (ConfigurationSettings.AppSettings [Setting]);
  74
+		}
  75
+
  76
+		static public IDbConnection CreateConnection(string ConnectionString)
  77
+		{
  78
+			if (ConnectionString == null) 
  79
+				throw new System.ArgumentNullException ("ConnectionString");
  80
+
  81
+			string [] ConnectionAttributes = ConnectionString.Split (new Char [1] { ';' }); 
  82
+			string ProviderName = null;
  83
+			string NewConnectionString = "";
  84
+			foreach (string s in ConnectionAttributes) {
  85
+				string [] AttributeParts = s.Split (new Char [1] { '=' });
  86
+				if (AttributeParts [0].ToLower ().Trim () == "factory")
  87
+					ProviderName = AttributeParts [1].Trim ();
  88
+				else 
  89
+					NewConnectionString += ";" + s;
  90
+			}
  91
+			NewConnectionString = NewConnectionString.Remove (0, 1); // remove the initial semicolon
  92
+			if (ProviderName == null) 
  93
+				throw new System.ArgumentException ("The connection string must contain a 'factory=Provider.Class' token", "ConnectionString");
  94
+			return CreateConnection (ProviderName, NewConnectionString);
  95
+		}
  96
+
  97
+		static public IDbConnection CreateConnection(string ProviderName, string ConnectionString)
  98
+		{
  99
+			if (ProviderName == null) 
  100
+				throw new System.ArgumentNullException("ProviderName");
  101
+			if (ConnectionString == null) 
  102
+				throw new System.ArgumentNullException ("ConnectionString");
  103
+
  104
+			Provider provider = providers [ProviderName];
  105
+
  106
+			if (provider == null)
  107
+				throw new ArgumentException ("ProviderName", "The specified provider does not exist");
  108
+			
  109
+			IDbConnection conn = provider.CreateConnection ();
  110
+			conn.ConnectionString = ConnectionString;
  111
+			return conn;
  112
+		}
  113
+
  114
+		static public IDbCommand CreateStoredProc (IDbConnection Conn, string CommandName)
  115
+		{
  116
+			if (Conn == null) 
  117
+				throw new System.ArgumentNullException ("Conn");
  118
+			if (CommandName == null) 
  119
+				throw new System.ArgumentNullException ("CommandName");
  120
+
  121
+			IDbCommand cmd = Conn.CreateCommand ();
  122
+			cmd.CommandText = CommandName;
  123
+			cmd.CommandType = CommandType.StoredProcedure;
  124
+			return cmd;
  125
+		}
  126
+
  127
+		static public IDbDataAdapter CreateDataAdapter (IDbCommand SelectCommand)
  128
+		{
  129
+			if (SelectCommand == null) 
  130
+				throw new System.ArgumentNullException("SelectCommand");
  131
+
  132
+			Provider provider = providers.FindByCommandType (SelectCommand.GetType ());
  133
+			IDbDataAdapter adapter = provider.CreateDataAdapter ();
  134
+			adapter.SelectCommand = SelectCommand;
  135
+			return adapter;
  136
+		}
  137
+
  138
+		static public IDbDataAdapter CreateDataAdapter (string ProviderName)
  139
+		{
  140
+			if (ProviderName == null) 
  141
+				throw new System.ArgumentNullException("ProviderName");
  142
+
  143
+			Provider provider = providers [ProviderName];
  144
+			IDbDataAdapter adapter = provider.CreateDataAdapter ();
  145
+			return adapter;
  146
+		}
  147
+
  148
+		static public IDbDataAdapter CreateDataAdapter (IDbConnection Conn, string SelectCommand)
  149
+		{
  150
+			if (Conn == null) 
  151
+				throw new System.ArgumentNullException ("Conn");
  152
+			if (SelectCommand == null) 
  153
+				throw new System.ArgumentNullException("SelectCommand");
  154
+
  155
+			IDbCommand cmd = Conn.CreateCommand ();
  156
+			cmd.CommandText = SelectCommand;
  157
+			return CreateDataAdapter (cmd);
  158
+		}
  159
+
  160
+		static public IDbCommand CreateCommand (string ProviderName)
  161
+		{
  162
+			if (ProviderName == null) 
  163
+				throw new System.ArgumentNullException("ProviderName");
  164
+
  165
+			Provider provider = providers [ProviderName];
  166
+			return provider.CreateCommand ();
  167
+		}
  168
+
  169
+		static public IDbCommand CreateCommand (IDbConnection Conn)
  170
+		{
  171
+			if (Conn == null) 
  172
+				throw new System.ArgumentNullException("Conn");
  173
+
  174
+			return Conn.CreateCommand ();
  175
+		}
  176
+
  177
+	}
  178
+}
80  Mono.Data/ProviderSectionHandler.cs
... ...
@@ -0,0 +1,80 @@
  1
+//
  2
+// Mono.Data.ProviderSectionHandler
  3
+//
  4
+// Authors:
  5
+//   Brian Ritchie (brianlritchie@hotmail.com) 
  6
+//  
  7
+//
  8
+// Copyright (C) Brian Ritchie, 2002
  9
+// 
  10
+
  11
+//
  12
+// Permission is hereby granted, free of charge, to any person obtaining
  13
+// a copy of this software and associated documentation files (the
  14
+// "Software"), to deal in the Software without restriction, including
  15
+// without limitation the rights to use, copy, modify, merge, publish,
  16
+// distribute, sublicense, and/or sell copies of the Software, and to
  17
+// permit persons to whom the Software is furnished to do so, subject to
  18
+// the following conditions:
  19
+// 
  20
+// The above copyright notice and this permission notice shall be
  21
+// included in all copies or substantial portions of the Software.
  22
+// 
  23
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30
+//
  31
+
  32
+using System;
  33
+using System.Xml;
  34
+using System.Configuration;
  35
+
  36
+namespace Mono.Data
  37
+{
  38
+#if NET_2_0
  39
+	[Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")]
  40
+#endif
  41
+	public class ProviderSectionHandler : IConfigurationSectionHandler
  42
+	{
  43
+		public virtual object Create (object parent, object configContext, XmlNode section)
  44
+		{
  45
+			if (section == null)
  46
+				throw new System.ArgumentNullException ("section");
  47
+
  48
+			ProviderCollection providers = new ProviderCollection ();
  49
+			
  50
+			XmlNodeList ProviderList = section.SelectNodes ("./provider");
  51
+
  52
+			foreach (XmlNode ProviderNode in ProviderList) {
  53
+				Provider provider = new Provider(
  54
+					GetStringValue (ProviderNode, "name", true),
  55
+					GetStringValue (ProviderNode, "connection", true),
  56
+					GetStringValue (ProviderNode, "adapter", true),
  57
+					GetStringValue (ProviderNode, "command", true),
  58
+					GetStringValue (ProviderNode, "assembly", true),
  59
+					GetStringValue (ProviderNode, "description", false),
  60
+					GetStringValue (ProviderNode, "parameterprefix", false),
  61
+					GetStringValue (ProviderNode, "commandbuilder", false));
  62
+				providers.Add (provider);
  63
+			}
  64
+			return providers;
  65
+		}
  66
+
  67
+		private string GetStringValue(XmlNode _node, string _attribute, bool required)
  68
+		{
  69
+			XmlNode a = _node.Attributes.RemoveNamedItem(_attribute);
  70
+			if (a == null) {
  71
+				if (required)
  72
+					throw new ConfigurationException("Attribute required: " + _attribute);
  73
+				else
  74
+					return null;
  75
+			}
  76
+			return a.Value;		
  77
+		}
  78
+	}
  79
+}
  80
+
114  Mono.Data/app.config
... ...
@@ -0,0 +1,114 @@
  1
+<?xml version="1.0" encoding="utf-8" ?>
  2
+<configuration>
  3
+	<configSections>
  4
+		<sectionGroup name="mono.data">
  5
+			<section name="providers" type="Mono.Data.ProviderSectionHandler,Mono.Data" />
  6
+		</sectionGroup>
  7
+	</configSections>
  8
+	<appSettings>