* FileSystemInfo.cs: corrected COM visibility of UTC properties
[mono.git] / mcs / class / Npgsql / Npgsql / NpgsqlConnectedState.cs
1 // Npgsql.NpgsqlConnectedState.cs
2 //
3 // Author:
4 //      Dave Joyner <d4ljoyn@yahoo.com>
5 //
6 //      Copyright (C) 2002 The Npgsql Development Team
7 //      npgsql-general@gborg.postgresql.org
8 //      http://gborg.postgresql.org/project/npgsql/projdisplay.php
9 //
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24
25 using System;
26 using System.IO;
27
28
29 namespace Npgsql
30 {
31     internal sealed class NpgsqlConnectedState : NpgsqlState
32     {
33
34         private static NpgsqlConnectedState _instance = null;
35
36         private NpgsqlConnectedState()
37         {}
38         public static NpgsqlConnectedState Instance
39         {
40             get
41             {
42                 if ( _instance == null )
43                 {
44                     _instance = new NpgsqlConnectedState();
45                 }
46                 return _instance;
47             }
48         }
49         public override void Startup(NpgsqlConnection context)
50         {
51             if (context.BackendProtocolVersion == ProtocolVersion.Version3)
52             {
53
54                 NpgsqlStartupPacket startupPacket  = new NpgsqlStartupPacket(296, //Not used.
55                                                      3,
56                                                      0,
57                                                      context.DatabaseName,
58                                                      context.UserName,
59                                                      "",
60                                                      "",
61                                                      "");
62
63                 startupPacket.WriteToStream( new BufferedStream(context.Stream), context.Encoding );
64                 ProcessBackendResponses( context );
65             }
66             else if (context.BackendProtocolVersion == ProtocolVersion.Version2)
67             {
68
69                 NpgsqlStartupPacket startupPacket  = new NpgsqlStartupPacket(296,
70                                                      2,
71                                                      0,
72                                                      context.DatabaseName,
73                                                      context.UserName,
74                                                      "",
75                                                      "",
76                                                      "");
77
78                 startupPacket.WriteToStream( new BufferedStream(context.Stream), context.Encoding );
79                 ProcessBackendResponses( context );
80
81
82             }
83
84         }
85
86     }
87 }