Ejemplo n.º 1
0
        private NpgsqlConnection(NpgsqlConnectionStringBuilder builder)
        {
            this.settings = builder;

            NoticeDelegate       = new NoticeEventHandler(OnNotice);
            NotificationDelegate = new NotificationEventHandler(OnNotification);

            ProvideClientCertificatesCallbackDelegate = new ProvideClientCertificatesCallback(DefaultProvideClientCertificatesCallback);
            CertificateValidationCallbackDelegate     = new CertificateValidationCallback(DefaultCertificateValidationCallback);
            CertificateSelectionCallbackDelegate      = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
            PrivateKeySelectionCallbackDelegate       = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback);

            // Fix authentication problems. See https://bugzilla.novell.com/show_bug.cgi?id=MONO77559 and
            // http://pgfoundry.org/forum/message.php?msg_id=1002377 for more info.
            RSACryptoServiceProvider.UseMachineKeyStore = true;

            promotable = new NpgsqlPromotableSinglePhaseNotification(this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Releases the connection to the database.  If the connection is pooled, it will be
        ///	made available for re-use.  If it is non-pooled, the actual connection will be shutdown.
        /// </summary>
        public override void Close()
        {
            if (connector != null)
            {
                Promotable.Prepare();
                // clear the way for another promotable transaction
                promotable = null;

                connector.Notification -= NotificationDelegate;
                connector.Notice       -= NoticeDelegate;
                connector.StateChanged -= connector_StateChanged;

                if (SyncNotification)
                {
                    connector.RemoveNotificationThread();
                }

                if (Pooling)
                {
                    NpgsqlConnectorPool.ConnectorPoolMgr.ReleaseConnector(this, connector);
                }
                else
                {
                    Connector.ProvideClientCertificatesCallback -= ProvideClientCertificatesCallbackDelegate;
                    Connector.CertificateSelectionCallback      -= CertificateSelectionCallbackDelegate;
                    Connector.CertificateValidationCallback     -= CertificateValidationCallbackDelegate;
                    Connector.PrivateKeySelectionCallback       -= PrivateKeySelectionCallbackDelegate;

                    if (Connector.Transaction != null)
                    {
                        Connector.Transaction.Cancel();
                    }

                    Connector.Close();
                }


                connector = null;

                this.OnStateChange(new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed));
            }
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Releases the connection to the database.  If the connection is pooled, it will be
		///	made available for re-use.  If it is non-pooled, the actual connection will be shutdown.
		/// </summary>
		public override void Close()
		{
			if (connector != null)
			{
				Promotable.Prepare();
				// clear the way for another promotable transaction
				promotable = null;

				connector.Notification -= NotificationDelegate;
				connector.Notice -= NoticeDelegate;
				connector.StateChanged -= connector_StateChanged;

				if (SyncNotification)
				{
					connector.RemoveNotificationThread();
				}

				if (Pooling)
				{
					NpgsqlConnectorPool.ConnectorPoolMgr.ReleaseConnector(this, connector);
				}
				else
				{
					Connector.ProvideClientCertificatesCallback -= ProvideClientCertificatesCallbackDelegate;
					Connector.CertificateSelectionCallback -= CertificateSelectionCallbackDelegate;
					Connector.CertificateValidationCallback -= CertificateValidationCallbackDelegate;
					Connector.PrivateKeySelectionCallback -= PrivateKeySelectionCallbackDelegate;

					if (Connector.Transaction != null)
					{
						Connector.Transaction.Cancel();
					}

					Connector.Close();
				}


				connector = null;

				this.OnStateChange(new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed));
			}
		}
Ejemplo n.º 4
0
		private NpgsqlConnection(NpgsqlConnectionStringBuilder builder)
		{
			this.settings = builder;

			NoticeDelegate = new NoticeEventHandler(OnNotice);
			NotificationDelegate = new NotificationEventHandler(OnNotification);

			ProvideClientCertificatesCallbackDelegate = new ProvideClientCertificatesCallback(DefaultProvideClientCertificatesCallback);
			CertificateValidationCallbackDelegate = new CertificateValidationCallback(DefaultCertificateValidationCallback);
			CertificateSelectionCallbackDelegate = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
			PrivateKeySelectionCallbackDelegate = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback);

			// Fix authentication problems. See https://bugzilla.novell.com/show_bug.cgi?id=MONO77559 and 
			// http://pgfoundry.org/forum/message.php?msg_id=1002377 for more info.
			RSACryptoServiceProvider.UseMachineKeyStore = true;

			promotable = new NpgsqlPromotableSinglePhaseNotification(this);
		}