Thread: [pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source PgConnection.cs,1.17,1.18
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos Guzm?n ?l. <car...@us...> - 2004-05-31 17:19:09
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13556 Modified Files: PgConnection.cs Log Message: 2004-05-31 Carlos Guzman Alvarez <car...@te...> * PostgreSql.Data.PgSqlClient/FbConnection.cs: * PostgreSql.Data.PgSqlClient/NPgClient/PgDbClient.cs: - Reworked information and notification message handling using callbacks (delegates) Index: PgConnection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgConnection.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PgConnection.cs 10 Apr 2004 20:15:33 -0000 1.17 --- PgConnection.cs 31 May 2004 17:18:57 -0000 1.18 *************** *** 59,65 **** private ArrayList activeCommands; - private PgClientMessageEventHandler infoMessageHandler; - private PgClientNotificationEventHandler notificationHandler; - #endregion --- 59,62 ---- *************** *** 202,206 **** #region Constructors ! public PgConnection() : base() { this.state = ConnectionState.Closed; --- 199,207 ---- #region Constructors ! public PgConnection() : this(null) ! { ! } ! ! public PgConnection(string connString) : base() { this.state = ConnectionState.Closed; *************** *** 208,216 **** GC.SuppressFinalize(this); ! } ! ! public PgConnection(string connString) : this() ! { ! this.ConnectionString = connString; } --- 209,217 ---- GC.SuppressFinalize(this); ! ! if (connString != null) ! { ! this.ConnectionString = connString; ! } } *************** *** 381,385 **** // Add handler for Ssl connections ! dbConnection.DB.SslConnectionDelegate = new SslConnectionCallback(this.OnSslConnection); // Open connection --- 382,386 ---- // Add handler for Ssl connections ! dbConnection.DB.SslConnection = new SslConnectionCallback(this.OnSslConnection); // Open connection *************** *** 397,401 **** // Set connection state to Open ! this.state = ConnectionState.Open; if (this.StateChange != null) { --- 398,402 ---- // Set connection state to Open ! this.state = ConnectionState.Open; if (this.StateChange != null) { *************** *** 407,416 **** // Add Info message event handler ! this.infoMessageHandler = new PgClientMessageEventHandler(OnInfoMessage); ! this.dbConnection.DB.InfoMessage += infoMessageHandler; // Add notification event handler ! this.notificationHandler = new PgClientNotificationEventHandler(OnNotification); ! this.dbConnection.DB.Notification += notificationHandler; } catch (PgClientException ex) --- 408,415 ---- // Add Info message event handler ! this.dbConnection.DB.InfoMessage = new InfoMessageCallback(this.OnInfoMessage); // Add notification event handler ! this.dbConnection.DB.Notification = new NotificationCallback(this.OnNotification); } catch (PgClientException ex) *************** *** 429,435 **** lock (this.dbConnection) { // Close DataReader ! if (this.dataReader != null && ! !this.dataReader.IsClosed) { this.dataReader.Close(); --- 428,439 ---- lock (this.dbConnection) { + // Remove info message callback + this.dbConnection.DB.InfoMessage = null; + + // Remove notification callback + this.dbConnection.DB.Notification = null; + // Close DataReader ! if (this.dataReader != null && !this.dataReader.IsClosed) { this.dataReader.Close(); *************** *** 446,461 **** } - // Remove info message event handler - if (this.infoMessageHandler != null) - { - this.dbConnection.DB.InfoMessage -= this.infoMessageHandler; - } - - // Remove notification event handler - if (this.notificationHandler != null) - { - this.dbConnection.DB.Notification -= this.notificationHandler; - } - // Remove SSL handlers this.ServerCertValidation = null; --- 450,453 ---- *************** *** 611,634 **** #region Event Handlers Methods ! private void OnInfoMessage(object sender, PgClientMessageEventArgs e) { ! if (InfoMessage != null) { ! InfoMessage(this, new PgInfoMessageEventArgs(e.Exception)); } } ! private void OnNotification(object sender, PgClientNotificationEventArgs e) { ! if (Notification != null) { ! Notification(this, ! new PgNotificationEventArgs( ! e.ProcessID, ! e.Condition, ! e.Aditional)); } } private bool OnServerCertificateValidation( X509Certificate certificate, --- 603,636 ---- #region Event Handlers Methods ! private void OnInfoMessage(PgClientException ex) { ! if (this.InfoMessage != null) { ! this.InfoMessage(this, new PgInfoMessageEventArgs(ex)); } } ! private void OnNotification(int processID, string condition, string aditional) { ! if (this.Notification != null) { ! this.Notification(this, new PgNotificationEventArgs(processID, condition, aditional)); } } + private void OnSslConnection() + { + PgDbClient db = this.dbConnection.DB; + + // Server certificate validation + db.SslClientStream.ServerCertValidationDelegate = new CertificateValidationCallback(OnServerCertificateValidation); + + // Client certificate selection + db.SslClientStream.ClientCertSelectionDelegate = new CertificateSelectionCallback(OnClientCertificateSelection); + + // Private key selection + db.SslClientStream.PrivateKeyCertSelectionDelegate = new PrivateKeySelectionCallback(OnPrivateKeySelection); + } + private bool OnServerCertificateValidation( X509Certificate certificate, *************** *** 673,688 **** } - private void OnSslConnection() - { - // Server certificate validation - dbConnection.DB.SslClientStream.ServerCertValidationDelegate = new CertificateValidationCallback(OnServerCertificateValidation); - - // Client certificate selection - dbConnection.DB.SslClientStream.ClientCertSelectionDelegate = new CertificateSelectionCallback(OnClientCertificateSelection); - - // Private key selection - dbConnection.DB.SslClientStream.PrivateKeyCertSelectionDelegate = new PrivateKeySelectionCallback(OnPrivateKeySelection); - } - #endregion } --- 675,678 ---- |