/// <summary>
        /// Release resources.
        /// </summary>
        /// <param name = "disposing">
        /// If disposing equals true, Managed and unmanaged resources are disposed. if false, Only unmanaged resources
        /// can be disposed.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed and unmanaged resources.
                if (disposing)
                {
                    // Free managed resources & other reference types:
                    if (this.sslStream != null)
                    {
                        this.sslStream.Dispose();
                        this.sslStream = null;
                    }
                    if (this.streamProxy != null)
                    {
                        this.streamProxy.Dispose();
                        this.streamProxy = null;
                    }
                }

                // Call the appropriate methods to clean up unmanaged resources.
                // If disposing is false, only the following code is executed:

                this.disposed = true;
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="transport">
        /// an AdtsLdapClient object that provides the transport for SslAuthenticate.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// thrown when transport is null.
        /// </exception>
        public AdtsLdapSslTlsSecurityLayer(AdtsLdapClient transport)
        {
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }

            this.clientTransport = transport;
            this.streamProxy = new AdtsLdapSecurityStream(this);
            this.sslStream = new SslStream(this.streamProxy);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="transport">
        /// an AdtsLdapClient object that provides the transport for SslAuthenticate.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// thrown when transport is null.
        /// </exception>
        public AdtsLdapSslTlsSecurityLayer(AdtsLdapClient transport)
        {
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }

            this.clientTransport = transport;
            this.streamProxy     = new AdtsLdapSecurityStream(this);
            this.sslStream       = new SslStream(this.streamProxy);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="transport">
        /// an AdtsLdapServer object that provides the transport for SslAuthenticate.
        /// </param>
        /// <param name="context">
        /// an AdtsLdapContext object that provides the transport context for SslAuthenticate.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// thrown when transport is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// thrown when context is null.
        /// </exception>
        public AdtsLdapSslTlsSecurityLayer(AdtsLdapServer transport, AdtsLdapContext context)
        {
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.serverTransport = transport;
            this.serverContext   = context;
            this.streamProxy     = new AdtsLdapSecurityStream(this);
            this.sslStream       = new SslStream(this.streamProxy);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="transport">
        /// an AdtsLdapServer object that provides the transport for SslAuthenticate.
        /// </param>
        /// <param name="context">
        /// an AdtsLdapContext object that provides the transport context for SslAuthenticate.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// thrown when transport is null.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// thrown when context is null.
        /// </exception>
        public AdtsLdapSslTlsSecurityLayer(AdtsLdapServer transport, AdtsLdapContext context)
        {
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.serverTransport = transport;
            this.serverContext = context;
            this.streamProxy = new AdtsLdapSecurityStream(this);
            this.sslStream = new SslStream(this.streamProxy);
        }
        /// <summary>
        /// Release resources. 
        /// </summary>
        /// <param name = "disposing">
        /// If disposing equals true, Managed and unmanaged resources are disposed. if false, Only unmanaged resources 
        /// can be disposed. 
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed and unmanaged resources.
                if (disposing)
                {
                    // Free managed resources & other reference types:
                    if (this.sslStream != null)
                    {
                        this.sslStream.Dispose();
                        this.sslStream = null;
                    }
                    if (this.streamProxy != null)
                    {
                        this.streamProxy.Dispose();
                        this.streamProxy = null;
                    }
                }

                // Call the appropriate methods to clean up unmanaged resources.
                // If disposing is false, only the following code is executed:

                this.disposed = true;
            }

            base.Dispose(disposing);
        }