2010-04-07 Jb Evain <jbevain@novell.com>
[mcs.git] / class / Npgsql / Npgsql / NpgsqlFactory.cs
blob446cb6609b9f3ceaea03415fb835b93b5a23fe29
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.
27 using System;
28 using System.ComponentModel;
29 using System.Data;
30 using System.Data.Common;
32 namespace Npgsql
34 /// <summary>
35 /// A factory to create instances of various Npgsql objects.
36 /// </summary>
37 [Serializable]
38 public sealed class NpgsqlFactory : DbProviderFactory, IServiceProvider
40 public static NpgsqlFactory Instance = new NpgsqlFactory();
43 private NpgsqlFactory()
48 /// <summary>
49 /// Creates an NpgsqlCommand object.
50 /// </summary>
51 public override DbCommand CreateCommand()
53 return (DbCommand) (IDbCommand) new NpgsqlCommand();
57 public override DbCommandBuilder CreateCommandBuilder()
59 return (DbCommandBuilder) (Component) new NpgsqlCommandBuilder();
62 public override DbConnection CreateConnection()
64 return (DbConnection) (IDbConnection) new NpgsqlConnection();
67 public override DbDataAdapter CreateDataAdapter()
69 return (DbDataAdapter) (IDbDataAdapter) new NpgsqlDataAdapter();
72 public override DbParameter CreateParameter()
74 return (DbParameter) (IDbDataParameter) new NpgsqlParameter();
77 #if NET_2_0
78 public override DbConnectionStringBuilder CreateConnectionStringBuilder()
80 return new NpgsqlConnectionStringBuilder();
82 #endif
83 #region IServiceProvider Members
85 public object GetService(Type serviceType)
87 #if ENTITIES
88 if (serviceType == typeof(DbProviderServices))
89 return NpgsqlServices.Instance;
90 else
91 #endif
92 return null;
95 #endregion