Make System.Web.Script.Serialization.JavaScriptSerializer.ConvertToType(Type, object...
[mono.git] / mcs / class / Npgsql / Npgsql / NpgsqlFactory.cs
1 // Npgsql.NpgsqlFactory.cs
2 //
3 // Author:
4 //      Francisco Jr. (fxjrlists@yahoo.com.br)
5 //      Veerapuram Varadhan  (vvaradhan@novell.com)
6 //
7 //      Copyright (C) 2002-2006 The Npgsql Development Team
8 //      Copyright (C) 2009 Novell Inc
9 //
10 // Permission to use, copy, modify, and distribute this software and its
11 // documentation for any purpose, without fee, and without a written
12 // agreement is hereby granted, provided that the above copyright notice
13 // and this paragraph and the following two paragraphs appear in all copies.
14 // 
15 // IN NO EVENT SHALL THE NPGSQL DEVELOPMENT TEAM BE LIABLE TO ANY PARTY
16 // FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
17 // INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
18 // DOCUMENTATION, EVEN IF THE NPGSQL DEVELOPMENT TEAM HAS BEEN ADVISED OF
19 // THE POSSIBILITY OF SUCH DAMAGE.
20 // 
21 // THE NPGSQL DEVELOPMENT TEAM SPECIFICALLY DISCLAIMS ANY WARRANTIES,
22 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23 // AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
24 // ON AN "AS IS" BASIS, AND THE NPGSQL DEVELOPMENT TEAM HAS NO OBLIGATIONS
25 // TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
26
27 using System;
28 using System.ComponentModel;
29 using System.Data;
30 using System.Data.Common;
31
32 namespace Npgsql
33 {
34         /// <summary>
35         /// A factory to create instances of various Npgsql objects.
36         /// </summary>
37         [Serializable]
38         public sealed class NpgsqlFactory : DbProviderFactory, IServiceProvider
39         {
40                 public static NpgsqlFactory Instance = new NpgsqlFactory();
41
42
43                 private NpgsqlFactory()
44                 {
45                 }
46
47
48                 /// <summary>
49                 /// Creates an NpgsqlCommand object.
50                 /// </summary>
51                 public override DbCommand CreateCommand()
52                 {
53                         return (DbCommand) (IDbCommand) new NpgsqlCommand();
54                 }
55
56
57                 public override DbCommandBuilder CreateCommandBuilder()
58                 {
59                         return (DbCommandBuilder) (Component) new NpgsqlCommandBuilder();
60                 }
61
62                 public override DbConnection CreateConnection()
63                 {
64                     return (DbConnection) (IDbConnection) new NpgsqlConnection();
65                 }
66
67                 public override DbDataAdapter CreateDataAdapter()
68                 {
69                     return (DbDataAdapter) (IDbDataAdapter) new NpgsqlDataAdapter();
70                 }
71
72                 public override DbParameter CreateParameter()
73                 {
74                     return (DbParameter) (IDbDataParameter) new NpgsqlParameter();
75                 }
76
77 #if NET_2_0
78                 public override DbConnectionStringBuilder CreateConnectionStringBuilder()
79                 {
80                         return new NpgsqlConnectionStringBuilder();
81                 }
82 #endif
83                 #region IServiceProvider Members
84
85                 public object GetService(Type serviceType)
86                 {
87 #if ENTITIES
88             if (serviceType == typeof(DbProviderServices))
89                 return NpgsqlServices.Instance;
90             else
91 #endif
92                         return null;
93                 }
94
95                 #endregion
96         }
97 }