Exemplo n.º 1
0
        /// <summary>
        /// Create the transport listener for the service host endpoint.
        /// </summary>
        /// <param name="endpointUri">The endpoint Uri.</param>
        /// <param name="endpoints">The description of the endpoints.</param>
        /// <param name="endpointConfiguration">The configuration of the endpoints.</param>
        /// <param name="listener">The transport listener.</param>
        /// <param name="certificateValidator">The certificate validator for the transport.</param>
        public virtual void CreateServiceHostEndpoint(
            Uri endpointUri,
            EndpointDescriptionCollection endpoints,
            EndpointConfiguration endpointConfiguration,
            ITransportListener listener,
            ICertificateValidator certificateValidator
            )
        {
            // create the stack listener.
            try
            {
                TransportListenerSettings settings = new TransportListenerSettings();

                settings.Descriptions         = endpoints;
                settings.Configuration        = endpointConfiguration;
                settings.ServerCertificate    = InstanceCertificate;
                settings.CertificateValidator = certificateValidator;
                settings.NamespaceUris        = MessageContext.NamespaceUris;
                settings.Factory = MessageContext.Factory;

                listener.Open(
                    endpointUri,
                    settings,
                    GetEndpointInstance(this));

                TransportListeners.Add(listener);

                listener.ConnectionStatusChanged += OnConnectionStatusChanged;
            }
            catch (Exception e)
            {
                string message = $"Could not load {endpointUri.Scheme} Stack Listener.";
                if (e.InnerException != null)
                {
                    message += (" " + e.InnerException.Message);
                }
                Utils.Trace(e, message);
                throw;
            }
        }