From: Miguel de Icaza Date: Tue, 2 Mar 2010 02:40:23 +0000 (-0000) Subject: Moved deprecated library X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=56a7738589a93d801d41d8262067eac0b087ba0f;p=mono.git Moved deprecated library svn path=/trunk/mcs/; revision=152781 --- diff --git a/mcs/class/Mono.Data/AssemblyInfo.cs b/mcs/class/Mono.Data/AssemblyInfo.cs deleted file mode 100644 index e06154cd236..00000000000 --- a/mcs/class/Mono.Data/AssemblyInfo.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -// AssemblyInfo.cs -// -// Author: -// Andreas Nahr (ClassDevelopment@A-SoftTech.com) -// -// (C) 2003 Ximian, Inc. http://www.ximian.com -// (C) 2004 Novell (http://www.novell.com) -// - -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyVersion (Consts.FxVersion)] - -/* TODO COMPLETE INFORMATION - -[assembly: AssemblyTitle ("")] -[assembly: AssemblyDescription ("")] - -[assembly: CLSCompliant (true)] -[assembly: AssemblyFileVersion ("0.0.0.1")] - -[assembly: ComVisible (false)] - -*/ - -[assembly: AssemblyDelaySign (true)] -[assembly: AssemblyKeyFile ("../mono.pub")] - diff --git a/mcs/class/Mono.Data/ChangeLog b/mcs/class/Mono.Data/ChangeLog deleted file mode 100644 index e328c451316..00000000000 --- a/mcs/class/Mono.Data/ChangeLog +++ /dev/null @@ -1,61 +0,0 @@ -2008-12-30 Gert Driesen - - * DataTools.cs - * Provider.cs - * ProviderCollection.cs - * ProviderFactory.cs: Fixed line endings. - -2008-09-06 Daniel Morgan - - * ProviderSectionHandler.cs - * ProviderFactory.cs - * ProviderCollection.cs - * DataTools.cs - * Provider.cs: for the NET_2_0 profile, - added Obsolete attribute - to all classes in assembly Mono.Data because it - has been superceded by DbProviderFactories in System.Data - -2006-02-13 Daniel Morgan - - * ProviderSectionHandler.cs - * Provider.cs: add support - for parameter prefix and command builder - - * app.config: updated the sample app.config file - to include parameterprefix and commandbuilder on - some providers - -2006-02-13 Daniel Morgan - - Patches from Brad Langhorst - - * ProviderSectionHandler.cs - * ProviderFactory - * ProviderCollection.cs - * DataTools.cs - * Provider.cs: catch invalid args, - allow non-qualified assembly loading, - warn about empty providers - -2005-12-31 Daniel Morgan - - * test/test.exe.config - * app.config: add new ADO.NET providers, remove obsolete providers, and - add more sample connection strings - - * Provider.cs: load providers internal to System.Data differently than those - that are external, better error handling for assembly or connection class not found - -2004-03-30 Lluis Sanchez Gual - - * DataTools.cs: in FillDataSet(string,SelectCommand), use the connection - got from the configuration file to create the data adapter. Patch by - Matthijs ter Woord. - -2003-12-15 Gonzalo Paniagua Javier - - * ProviderSectionHandler.cs: use XPath to get the providers to avoid - getting an exception when there's whitespace, comments... Patch by Marco - Canini . - diff --git a/mcs/class/Mono.Data/DataTools.cs b/mcs/class/Mono.Data/DataTools.cs deleted file mode 100644 index 9f830211380..00000000000 --- a/mcs/class/Mono.Data/DataTools.cs +++ /dev/null @@ -1,133 +0,0 @@ -// -// Mono.Data.DataTools -// -// Authors: -// Brian Ritchie (brianlritchie@hotmail.com) -// -// -// Copyright (C) Brian Ritchie, 2002 -// -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -using System; -using System.Data; - -namespace Mono.Data -{ - /// - /// Summary description for ProviderTools. - /// -#if NET_2_0 - [Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")] -#endif - public class DataTools - { - public DataTools() - { - } - - static public IDataParameter AddParameter(IDbCommand Cmd, string ParameterName, DbType DbType, - ParameterDirection Direction) - { - if (Cmd == null) - throw new System.ArgumentNullException ("Cmd"); - if (ParameterName == null) - throw new System.ArgumentNullException ("ParameterName"); - - IDataParameter param = Cmd.CreateParameter (); - Cmd.Parameters.Add (param); - param.ParameterName = ParameterName; - param.Direction = Direction; - param.DbType = DbType; - return param; - } - - static public IDataParameter AddParameter(IDbCommand Cmd, string ParameterName, DbType DbType) - { - if (Cmd == null) - throw new System.ArgumentNullException ("Cmd"); - if (ParameterName == null) - throw new System.ArgumentNullException("ParameterName"); - - IDataParameter param = Cmd.CreateParameter (); - Cmd.Parameters.Add (param); - param.ParameterName = ParameterName; - param.DbType = DbType; - return param; - } - - static public DataSet FillDataSet (IDbConnection conn, string SelectCommand) - { - if (conn == null) - throw new System.ArgumentNullException ("conn"); - if (SelectCommand == null) - throw new System.ArgumentNullException ("SelectCommand"); - - DataSet ds = new DataSet (); - IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (conn, SelectCommand); - if (conn.State != ConnectionState.Open) - conn.Open (); - adapter.Fill (ds); - return ds; - } - - static public DataSet FillDataSet(IDbCommand SelectCommand) - { - if (SelectCommand == null) - throw new System.ArgumentNullException ("SelectCommand"); - - DataSet ds = new DataSet (); - IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (SelectCommand); - if (adapter.SelectCommand.Connection.State != ConnectionState.Open) - adapter.SelectCommand.Connection.Open (); - adapter.Fill (ds); - return ds; - } - - static public DataSet FillDataSet(string ConfigSetting, string SelectCommand) - { - if (ConfigSetting == null) - throw new System.ArgumentNullException ("ConfigSetting"); - if (SelectCommand == null) - throw new System.ArgumentNullException ("SelectCommand"); - - IDbConnection conn = ProviderFactory.CreateConnectionFromConfig (ConfigSetting); - conn.Open (); - DataSet ds = null; - try - { - ds = new DataSet (); - IDbDataAdapter adapter = ProviderFactory.CreateDataAdapter (conn, SelectCommand); - adapter.Fill (ds); - } - finally - { - conn.Close (); - } - return ds; - } - - - } -} - diff --git a/mcs/class/Mono.Data/Makefile b/mcs/class/Mono.Data/Makefile deleted file mode 100644 index 8f88c841d7b..00000000000 --- a/mcs/class/Mono.Data/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -thisdir = class/Mono.Data -SUBDIRS = -include ../../build/rules.make - -LIBRARY = Mono.Data.dll -LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:System.Xml.dll \ - /r:System.Data.dll -NO_TEST = yes - -include ../../build/library.make diff --git a/mcs/class/Mono.Data/Mono.Data.dll.sources b/mcs/class/Mono.Data/Mono.Data.dll.sources deleted file mode 100644 index 6eeaebae41c..00000000000 --- a/mcs/class/Mono.Data/Mono.Data.dll.sources +++ /dev/null @@ -1,7 +0,0 @@ -AssemblyInfo.cs -../../build/common/Consts.cs -DataTools.cs -Provider.cs -ProviderCollection.cs -ProviderFactory.cs -ProviderSectionHandler.cs diff --git a/mcs/class/Mono.Data/Provider.cs b/mcs/class/Mono.Data/Provider.cs deleted file mode 100644 index 2369bbfdf7d..00000000000 --- a/mcs/class/Mono.Data/Provider.cs +++ /dev/null @@ -1,268 +0,0 @@ -// -// Mono.Data.Provider -// -// Authors: -// Brian Ritchie (brianlritchie@hotmail.com) -// -// -// Copyright (C) Brian Ritchie, 2002 -// -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -using System; -using System.Data; -using System.Reflection; -using System.IO; - -namespace Mono.Data -{ -#if NET_2_0 - [Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")] -#endif - public class Provider - { - private string name = null; - private string connectionTypeName; - private string adapterTypeName; - private string commandTypeName; - private Type connectionType; - private Type adapterType; - private Type commandType; - private Assembly providerAssembly; - private string assemblyName; - private string description; - private string parameterprefix; - private string commandBuilderTypeName = String.Empty; - private Type commandBuilderType; - - public Provider(string _name, string _connection, - string _dataadapter, string _command, string _assembly, - string _description) - { - name = _name; - connectionTypeName = _connection; - adapterTypeName = _dataadapter; - assemblyName = _assembly; - commandTypeName = _command; - description = _description; - } - - public Provider(string _name, string _connection, - string _dataadapter, string _command, string _assembly, - string _description, string _parameterprefix, string _commandbuilder) - { - name = _name; - connectionTypeName = _connection; - adapterTypeName = _dataadapter; - assemblyName = _assembly; - commandTypeName = _command; - description = _description; - - switch(_parameterprefix) { - case "colon": - parameterprefix = ":"; // named parameter prefixed by a semicolon - break; - case "at": - parameterprefix = "@"; // named parameter prefixed by an at symbol - break; - case "questionmark": - parameterprefix = "?"; // postional parameter noted by the question mark - break; - } - - commandBuilderTypeName = _commandbuilder; - } - - public Provider(string _name, Type _connection, Type _dataadapter, Type _command, - string _description) - { - if (_connection == null) - throw new System.ArgumentNullException ("_connection"); - if (_dataadapter == null) - throw new System.ArgumentNullException ("_dataadapter"); - if (_command == null) - throw new System.ArgumentNullException ("_command"); - - name = _name; - connectionTypeName = _connection.FullName; - adapterTypeName = _dataadapter.FullName; - commandTypeName = _command.FullName; - connectionType = _connection; - adapterType = _dataadapter; - commandType = _command; - description = _description; - } - - public string Name - { - get {return name;} - } - - public string Description - { - get {return description;} - } - - public string ParameterPrefix - { - get {return parameterprefix;} - } - - public Assembly ProviderAssembly { - get { - if (providerAssembly == null) { - if (assemblyName.IndexOf(',') == -1) //try to load with a partial name if that's all we have - providerAssembly = Assembly.LoadWithPartialName (assemblyName); - else - providerAssembly = Assembly.Load (assemblyName); - } - - return providerAssembly; - } - } - - public Type ConnectionType - { - get { - if (connectionType == null) { - connectionType = ProviderAssembly.GetType (connectionTypeName, false); - if (connectionType == null) { - throw new Exception (String.Format ("Unable to load type of connection class: {0} from assembly: {1}", - connectionTypeName, assemblyName)); - } - } - return connectionType; - } - } - - public Type DataAdapterType - { - get { - if (adapterType == null) { - adapterType = ProviderAssembly.GetType (adapterTypeName, false); - if (adapterType == null) { - throw new Exception (String.Format ("Unable to load type of adapter class: {0} from assembly: {1}", - adapterTypeName, assemblyName)); - } - } - return adapterType; - } - } - - public Type CommandType { - get { - if (commandType == null) { - commandType = ProviderAssembly.GetType (commandTypeName, false); - if (commandType == null) { - throw new Exception (String.Format ("Unable to load type of command class: {0} from assembly: {1}", - commandTypeName, assemblyName)); - } - } - return commandType; - } - } - - public Type CommandBuilderType { - get { - if (commandBuilderType == null) { - if (commandBuilderTypeName.Equals(String.Empty)) - throw new Exception("Provider does not have CommandBuilder type defined."); - commandBuilderType = ProviderAssembly.GetType (commandBuilderTypeName, false); - if (commandBuilderType == null) { - throw new Exception (String.Format ("Unable to load type of command class: {0} from assembly: {1}", - commandBuilderTypeName, assemblyName)); - } - } - return commandBuilderType; - } - } - - public IDbConnection CreateConnection() - { - object connObj = null; - - switch (Name) { - case "System.Data.SqlClient": - connObj = new System.Data.SqlClient.SqlConnection (); - break; - case "System.Data.Odbc": - connObj = new System.Data.Odbc.OdbcConnection (); - break; - case "System.Data.OleDb": - connObj = new System.Data.OleDb.OleDbConnection (); - break; - default: - connObj = Activator.CreateInstance (ConnectionType); - break; - } - - if (connObj == null) - throw new Exception (String.Format ("Unable to create instance of connection class: {0} from assembly: {1}", - connectionTypeName, assemblyName)); - - return (IDbConnection) connObj; - } - - public IDbDataAdapter CreateDataAdapter() - { - object adapterObj = Activator.CreateInstance (DataAdapterType); - if (adapterObj == null) - throw new Exception (String.Format ("Unable to create instance of adapter class: {0} from assembly: {1}", - adapterTypeName, assemblyName)); - - return (IDbDataAdapter) adapterObj; - } - - public IDbCommand CreateCommand() - { - object commandObj = Activator.CreateInstance (CommandType); - if (commandObj == null) - throw new Exception (String.Format ("Unable to create instance of command class: {0} from assembly: {1}", - commandTypeName, assemblyName)); - - return (IDbCommand) commandObj; - } - - public object CreateCommandBuilder(IDbDataAdapter adapter) - { - if (adapter == null) - throw new System.ArgumentNullException ("adapter"); - - object obj = (object) adapter; - if (!DataAdapterType.ToString ().Equals (obj.ToString ())) - throw new System.ArgumentException ("adapter not part of this provider."); - - if (commandBuilderTypeName.Equals (String.Empty)) - throw new Exception ("Provider does not have CommandBuilder type defined."); - - object[] parms = new object [] { obj }; - object commandBuilderObj = Activator.CreateInstance (CommandBuilderType, parms); - if (commandBuilderObj == null) - throw new Exception (String.Format ("Unable to create instance of command builder class: {0} from assembly: {1}", - commandBuilderTypeName, assemblyName)); - - return commandBuilderObj; - } - } -} - diff --git a/mcs/class/Mono.Data/ProviderCollection.cs b/mcs/class/Mono.Data/ProviderCollection.cs deleted file mode 100644 index 0cadc51aa57..00000000000 --- a/mcs/class/Mono.Data/ProviderCollection.cs +++ /dev/null @@ -1,323 +0,0 @@ -// -// Mono.Data.ProviderCollection -// -// Authors: -// Brian Ritchie (brianlritchie@hotmail.com) -// -// -// Copyright (C) Brian Ritchie, 2002 -// -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -namespace Mono.Data -{ - using System; - using System.Collections; - using System.Collections.Specialized; - - - /// - /// - /// A collection that stores objects. - /// - /// - /// - [Serializable ()] -#if NET_2_0 - [Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")] -#endif - public class ProviderCollection : DictionaryBase - { - - /// - /// - /// Initializes a new instance of . - /// - /// - public ProviderCollection () - - { - } - - /// - /// - /// Initializes a new instance of based on another . - /// - /// - /// - /// A from which the contents are copied - /// - public ProviderCollection (ProviderCollection value) - { - if (value == null) - throw new System.ArgumentNullException ("value"); - - this.AddRange (value); - } - - /// - /// - /// Initializes a new instance of containing any array of objects. - /// - /// - /// - /// A array of objects with which to intialize the collection - /// - public ProviderCollection (Provider[] value) - { - if (value == null) - throw new System.ArgumentNullException ("value"); - - this.AddRange (value); - } - - /// - /// Represents the entry at the specified index of the . - /// - /// The zero-based index of the entry to locate in the collection. - /// - /// The entry at the specified index of the collection. - /// - /// is outside the valid range of indexes for the collection. - public Provider this [string Name] - { - get { - return ((Provider)(Dictionary [Name])); - } - set { - Dictionary [Name] = value; - } - } - - public Provider FindByCommandType(Type CommandType) - { - if (CommandType == null) - throw new System.ArgumentNullException ("CommandType"); - - foreach (Provider p in this) { - if (p.CommandType == CommandType) - return p; - } - throw new IndexOutOfRangeException (); - } - - public Provider FindByDataAdapterType(Type DataAdapterType) - { - if (DataAdapterType == null) - throw new System.ArgumentNullException ("DataAdapterType"); - - foreach (Provider p in this) { - if (p.DataAdapterType == DataAdapterType) - return p; - } - throw new IndexOutOfRangeException (); - } - - public Provider FindByConnectionType(Type ConnectionType) - { - if (ConnectionType == null) - throw new System.ArgumentNullException("ConnectionType"); - - foreach (Provider p in this) { - if (p.ConnectionType == ConnectionType) - return p; - } - throw new IndexOutOfRangeException (); - } - - /// - /// Adds a with the specified value to the - /// . - /// - /// The to add. - /// - /// The index at which the new element was inserted. - /// - /// - public void Add(Provider value) - { - if (value == null) - throw new System.ArgumentNullException ("value"); - - Dictionary.Add (value.Name, value); - } - - /// - /// Copies the elements of an array to the end of the . - /// - /// - /// An array of type containing the objects to add to the collection. - /// - /// - /// None. - /// - /// - public void AddRange (Provider[] value) - { - if (value == null) - throw new System.ArgumentNullException ("value"); - - for (int i = 0; i < value.Length; i++) - this.Add (value [i]); - } - - /// - /// - /// Adds the contents of another to the end of the collection. - /// - /// - /// - /// A containing the objects to add to the collection. - /// - /// - /// None. - /// - /// - public void AddRange(ProviderCollection value) - { - if (value == null) - throw new System.ArgumentNullException ("value"); - - foreach (Provider p in value) - this.Add (p); - } - - /// - /// Gets a value indicating whether the - /// contains the specified . - /// - /// The to locate. - /// - /// if the is contained in the collection; - /// otherwise, . - /// - /// - public bool Contains (Provider value) - { - if (value == null) - throw new System.ArgumentNullException("value"); - - return Dictionary.Contains (value); - } - - /// - /// Copies the values to a one-dimensional instance at the - /// specified index. - /// - /// The one-dimensional that is the destination of the values copied from . - /// The index in where copying begins. - /// - /// None. - /// - /// is multidimensional. -or- The number of elements in the is greater than the available space between and the end of . - /// is . - /// is less than 's lowbound. - /// - public void CopyTo(Provider[] array, int index) - { - if (array == null) - throw new System.ArgumentNullException ("array"); - - Dictionary.CopyTo(array, index); - } - - /// - /// Returns an enumerator that can iterate through - /// the . - /// - /// None. - /// - public new ProviderEnumerator GetEnumerator () - { - return new ProviderEnumerator (this); - } - - /// - /// Removes a specific from the - /// . - /// - /// The to remove from the . - /// None. - /// is not found in the Collection. - public void Remove(Provider value) - { - if (value == null) - throw new System.ArgumentNullException ("value"); - - Dictionary.Remove(value); - } - - public class ProviderEnumerator : object, IEnumerator - { - - private IEnumerator baseEnumerator; - - private IEnumerable temp; - - public ProviderEnumerator(ProviderCollection mappings) - { - if (mappings == null) - throw new System.ArgumentNullException ("mappings"); - - this.temp = ((IEnumerable)(mappings)); - this.baseEnumerator = temp.GetEnumerator(); - } - - public Provider Current - { - get - { - return ((Provider) ((DictionaryEntry) (baseEnumerator.Current)).Value); - } - } - - object IEnumerator.Current - { - get - { - return baseEnumerator.Current; - } - } - - public bool MoveNext() - { - return baseEnumerator.MoveNext(); - } - - bool IEnumerator.MoveNext() - { - return baseEnumerator.MoveNext(); - } - - public void Reset() - { - baseEnumerator.Reset(); - } - - void IEnumerator.Reset() - { - baseEnumerator.Reset(); - } - } - } -} diff --git a/mcs/class/Mono.Data/ProviderFactory.cs b/mcs/class/Mono.Data/ProviderFactory.cs deleted file mode 100644 index 6a571bea086..00000000000 --- a/mcs/class/Mono.Data/ProviderFactory.cs +++ /dev/null @@ -1,178 +0,0 @@ -// -// Mono.Data.ProviderFactory -// -// Authors: -// Brian Ritchie (brianlritchie@hotmail.com) -// -// -// Copyright (C) Brian Ritchie, 2002 -// -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -using System; -using System.Data; -using System.Reflection; -using System.Runtime.Remoting; -using System.Configuration; -using System.Xml; -using System.Collections.Specialized; - -namespace Mono.Data -{ -#if NET_2_0 - [Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")] -#endif - public class ProviderFactory - { - private static ProviderCollection providers; - - static ProviderFactory () - { - providers = (ProviderCollection) ConfigurationSettings.GetConfig ("mono.data/providers"); - if (providers == null) { - providers = new ProviderCollection (); - // warn the developer or administrator that the provider list is empty - System.Diagnostics.Debug.Listeners.Add (new System.Diagnostics.TextWriterTraceListener (Console.Out)); - System.Diagnostics.Debug.WriteLine ("No providers found. Did you set up a mono.data/providers area in your app.config or in machine.config?"); - } - - } - - static public ProviderCollection Providers - { - get { - return providers; - } - } - - static public IDbConnection CreateConnectionFromConfig (string Setting) - { - if (Setting == null) - throw new System.ArgumentNullException ("Setting"); - - return CreateConnection (ConfigurationSettings.AppSettings [Setting]); - } - - static public IDbConnection CreateConnection(string ConnectionString) - { - if (ConnectionString == null) - throw new System.ArgumentNullException ("ConnectionString"); - - string [] ConnectionAttributes = ConnectionString.Split (new Char [1] { ';' }); - string ProviderName = null; - string NewConnectionString = ""; - foreach (string s in ConnectionAttributes) { - string [] AttributeParts = s.Split (new Char [1] { '=' }); - if (AttributeParts [0].ToLower ().Trim () == "factory") - ProviderName = AttributeParts [1].Trim (); - else - NewConnectionString += ";" + s; - } - NewConnectionString = NewConnectionString.Remove (0, 1); // remove the initial semicolon - if (ProviderName == null) - throw new System.ArgumentException ("The connection string must contain a 'factory=Provider.Class' token", "ConnectionString"); - return CreateConnection (ProviderName, NewConnectionString); - } - - static public IDbConnection CreateConnection(string ProviderName, string ConnectionString) - { - if (ProviderName == null) - throw new System.ArgumentNullException("ProviderName"); - if (ConnectionString == null) - throw new System.ArgumentNullException ("ConnectionString"); - - Provider provider = providers [ProviderName]; - - if (provider == null) - throw new ArgumentException ("ProviderName", "The specified provider does not exist"); - - IDbConnection conn = provider.CreateConnection (); - conn.ConnectionString = ConnectionString; - return conn; - } - - static public IDbCommand CreateStoredProc (IDbConnection Conn, string CommandName) - { - if (Conn == null) - throw new System.ArgumentNullException ("Conn"); - if (CommandName == null) - throw new System.ArgumentNullException ("CommandName"); - - IDbCommand cmd = Conn.CreateCommand (); - cmd.CommandText = CommandName; - cmd.CommandType = CommandType.StoredProcedure; - return cmd; - } - - static public IDbDataAdapter CreateDataAdapter (IDbCommand SelectCommand) - { - if (SelectCommand == null) - throw new System.ArgumentNullException("SelectCommand"); - - Provider provider = providers.FindByCommandType (SelectCommand.GetType ()); - IDbDataAdapter adapter = provider.CreateDataAdapter (); - adapter.SelectCommand = SelectCommand; - return adapter; - } - - static public IDbDataAdapter CreateDataAdapter (string ProviderName) - { - if (ProviderName == null) - throw new System.ArgumentNullException("ProviderName"); - - Provider provider = providers [ProviderName]; - IDbDataAdapter adapter = provider.CreateDataAdapter (); - return adapter; - } - - static public IDbDataAdapter CreateDataAdapter (IDbConnection Conn, string SelectCommand) - { - if (Conn == null) - throw new System.ArgumentNullException ("Conn"); - if (SelectCommand == null) - throw new System.ArgumentNullException("SelectCommand"); - - IDbCommand cmd = Conn.CreateCommand (); - cmd.CommandText = SelectCommand; - return CreateDataAdapter (cmd); - } - - static public IDbCommand CreateCommand (string ProviderName) - { - if (ProviderName == null) - throw new System.ArgumentNullException("ProviderName"); - - Provider provider = providers [ProviderName]; - return provider.CreateCommand (); - } - - static public IDbCommand CreateCommand (IDbConnection Conn) - { - if (Conn == null) - throw new System.ArgumentNullException("Conn"); - - return Conn.CreateCommand (); - } - - } -} diff --git a/mcs/class/Mono.Data/ProviderSectionHandler.cs b/mcs/class/Mono.Data/ProviderSectionHandler.cs deleted file mode 100644 index fa8758e2015..00000000000 --- a/mcs/class/Mono.Data/ProviderSectionHandler.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Mono.Data.ProviderSectionHandler -// -// Authors: -// Brian Ritchie (brianlritchie@hotmail.com) -// -// -// Copyright (C) Brian Ritchie, 2002 -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Xml; -using System.Configuration; - -namespace Mono.Data -{ -#if NET_2_0 - [Obsolete("ProviderFactory in assembly Mono.Data has been made obsolete by DbProviderFactories in assembly System.Data.")] -#endif - public class ProviderSectionHandler : IConfigurationSectionHandler - { - public virtual object Create (object parent, object configContext, XmlNode section) - { - if (section == null) - throw new System.ArgumentNullException ("section"); - - ProviderCollection providers = new ProviderCollection (); - - XmlNodeList ProviderList = section.SelectNodes ("./provider"); - - foreach (XmlNode ProviderNode in ProviderList) { - Provider provider = new Provider( - GetStringValue (ProviderNode, "name", true), - GetStringValue (ProviderNode, "connection", true), - GetStringValue (ProviderNode, "adapter", true), - GetStringValue (ProviderNode, "command", true), - GetStringValue (ProviderNode, "assembly", true), - GetStringValue (ProviderNode, "description", false), - GetStringValue (ProviderNode, "parameterprefix", false), - GetStringValue (ProviderNode, "commandbuilder", false)); - providers.Add (provider); - } - return providers; - } - - private string GetStringValue(XmlNode _node, string _attribute, bool required) - { - XmlNode a = _node.Attributes.RemoveNamedItem(_attribute); - if (a == null) { - if (required) - throw new ConfigurationException("Attribute required: " + _attribute); - else - return null; - } - return a.Value; - } - } -} - diff --git a/mcs/class/Mono.Data/app.config b/mcs/class/Mono.Data/app.config deleted file mode 100644 index 54c9a537de1..00000000000 --- a/mcs/class/Mono.Data/app.config +++ /dev/null @@ -1,114 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mcs/class/Mono.Data/test/test.cs b/mcs/class/Mono.Data/test/test.cs deleted file mode 100644 index eb1ef289c95..00000000000 --- a/mcs/class/Mono.Data/test/test.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Data; -using System.Data.SqlClient; -using Mono.Data; - -namespace testclient -{ - /// - /// Summary description for Class1. - /// - class Class1 - { - - public static void TestProviderFactory() - { - Console.WriteLine("Configured Providers:"); - foreach (Provider p in ProviderFactory.Providers) - Console.WriteLine(p.Description); - Console.WriteLine(); - Console.WriteLine("Connection Factory Test:"); - Console.WriteLine("Get Connection using PubsConnStr in app.config"); - IDbConnection conn=ProviderFactory.CreateConnectionFromConfig("PubsConnStr"); - Console.WriteLine("Open Connection"); - conn.Open(); - IDbCommand cmd=conn.CreateCommand(); - cmd.CommandText="select * from authors"; - IDataReader reader=cmd.ExecuteReader(); - reader.Read(); - Console.WriteLine(reader[0].ToString()); - Console.ReadLine(); - } - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - TestProviderFactory(); - - } - } -} diff --git a/mcs/class/Mono.Data/test/test.exe b/mcs/class/Mono.Data/test/test.exe deleted file mode 100755 index fe3af67bd99..00000000000 Binary files a/mcs/class/Mono.Data/test/test.exe and /dev/null differ diff --git a/mcs/class/Mono.Data/test/test.exe.config b/mcs/class/Mono.Data/test/test.exe.config deleted file mode 100644 index f93e8778c60..00000000000 --- a/mcs/class/Mono.Data/test/test.exe.config +++ /dev/null @@ -1,100 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -