1 // created on 30/7/2002 at 00:31
3 // Npgsql.NpgsqlMediator.cs
6 // Francisco Jr. (fxjrlists@yahoo.com.br)
8 // Copyright (C) 2002 The Npgsql Development Team
9 // npgsql-general@gborg.postgresql.org
10 // http://gborg.postgresql.org/project/npgsql/projdisplay.php
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Lesser General Public
14 // License as published by the Free Software Foundation; either
15 // version 2.1 of the License, or (at your option) any later version.
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 using System.Collections;
33 /// This class is responsible for serving as bridge between the backend
34 /// protocol handling and the core classes. It is used as the mediator for
35 /// exchanging data generated/sent from/to backend.
39 internal sealed class NpgsqlMediator
41 private ArrayList _errorMessages;
42 private ArrayList _resultSets;
43 private ArrayList _responses;
44 private ArrayList _notifications;
46 private NpgsqlRowDescription _rd;
47 private ArrayList _rows;
50 public NpgsqlMediator()
52 _errorMessages = new ArrayList();
53 _resultSets = new ArrayList();
54 _responses = new ArrayList();
55 _notifications = new ArrayList();
60 _errorMessages.Clear();
63 _notifications.Clear();
67 public ArrayList Errors
71 return _errorMessages;
75 public ArrayList Notifications
79 return _notifications;
84 public void AddNotification(NpgsqlNotificationEventArgs data)
86 _notifications.Add(data);
91 public void AddCompletedResponse(String response)
95 // Finished receiving the resultset. Add it to the buffer.
96 _resultSets.Add(new NpgsqlResultSet(_rd, _rows));
98 // Add a placeholder response.
101 // Discard the RowDescription.
106 // Add a placeholder resultset.
107 _resultSets.Add(null);
108 // It was just a non query string. Just add the response.
109 _responses.Add(response);
114 public void AddRowDescription(NpgsqlRowDescription rowDescription)
116 _rd = rowDescription;
117 _rows = new ArrayList();
120 public void AddAsciiRow(NpgsqlAsciiRow asciiRow)
125 public void AddBinaryRow(NpgsqlBinaryRow asciiRow)
131 public void AddBackendKeydata(NpgsqlBackEndKeyData keydata)
133 _responses.Add(keydata); //hack
136 public ArrayList GetResultSets()
141 public ArrayList GetCompletedResponses()
146 public NpgsqlBackEndKeyData GetBackEndKeyData()
148 return (NpgsqlBackEndKeyData)_responses[0]; //hack