2 // Mono.Data.Provider
\r
5 // Brian Ritchie (brianlritchie@hotmail.com)
\r
8 // Copyright (C) Brian Ritchie, 2002
\r
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:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
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.
34 using System.Reflection;
\r
38 public class Provider
\r
40 private string name = null;
\r
41 private string connectionTypeName;
\r
42 private string adapterTypeName;
\r
43 private string commandTypeName;
\r
44 private Type connectionType;
\r
45 private Type adapterType;
\r
46 private Type commandType;
\r
47 private string assemblyName;
\r
48 private string description;
\r
50 public Provider(string _name, string _connection,
\r
51 string _dataadapter, string _command, string _assembly,
\r
52 string _description)
\r
55 connectionTypeName = _connection;
\r
56 adapterTypeName = _dataadapter;
\r
57 assemblyName = _assembly;
\r
58 commandTypeName = _command;
\r
59 description = _description;
\r
62 public Provider(string _name, Type _connection, Type _dataadapter, Type _command,
\r
63 string _description)
\r
66 connectionTypeName = _connection.FullName;
\r
67 adapterTypeName = _dataadapter.FullName;
\r
68 commandTypeName = _command.FullName;
\r
69 connectionType = _connection;
\r
70 adapterType = _dataadapter;
\r
71 commandType = _command;
\r
72 description = _description;
\r
80 public string Description
\r
82 get {return description;}
\r
85 public Type ConnectionType
\r
89 if (connectionType==null)
\r
91 connectionType=Type.GetType(connectionTypeName+","+assemblyName);
\r
93 return connectionType;
\r
97 public Type DataAdapterType
\r
101 if (adapterType==null)
\r
103 adapterType=Type.GetType(adapterTypeName+","+assemblyName);
\r
105 return adapterType;
\r
109 public Type CommandType
\r
113 if (commandType==null)
\r
115 commandType=Type.GetType(commandTypeName+","+assemblyName);
\r
117 return commandType;
\r
121 public IDbConnection CreateConnection()
\r
123 return (IDbConnection) Activator.CreateInstance(ConnectionType);
\r
126 public IDbDataAdapter CreateDataAdapter()
\r
128 return (IDbDataAdapter) Activator.CreateInstance(DataAdapterType);
\r
131 public IDbCommand CreateCommand()
\r
133 return (IDbCommand) Activator.CreateInstance(CommandType);
\r