예제 #1
0
        /// <summary>
        /// Overrides the certificates given in app.config with the ones set programatically
        /// </summary>
        protected void OverrideConfig()
        {
            if (pListenerIdentity != null)
            {
                // Override certificate
                // TOOD: what is going on here? why only override the servicehost cridentials one time ?
                if (pListenerIdentity.ListenerCertificate != null && pServiceHost != null)
                {
                    pServiceHost.Credentials.ServiceCertificate.Certificate = pListenerIdentity.ListenerCertificate.Certificate;
                }
                else
                {
                    pListenerIdentity.ListenerCertificate = new OcesX509Certificate(pServiceHost.Credentials.ServiceCertificate.Certificate);
                }
            }
            else
            {
                CustomBinding           customBinding    = (CustomBinding)pServiceHost.Description.Endpoints[0].Binding;
                TransportBindingElement transportBinding = customBinding.Elements.Find <TransportBindingElement>();
                EmailTransport          emailTransport   = new EmailTransport(transportBinding);
                OcesX509Certificate     ocesCertificate  = new OcesX509Certificate(pServiceHost.Credentials.ServiceCertificate.Certificate);
                pListenerIdentity = new ListenerIdentity(emailTransport, ocesCertificate);
            }

            //Override transport binding
            pEmailBinding = GetEmailBinding();
            if (pListenerIdentity.Transport != null)
            {
                pEmailBinding.CopyElement((EmailBindingElement)pListenerIdentity.Transport.TransportBinding);
            }
            else
            {
                pListenerIdentity.Transport = new EmailTransport(pEmailBinding);
            }
        }
예제 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="listenerIdentity">A listener identity, defining this listener</param>
        public Listener(ListenerIdentity listenerIdentity)
        {
            this.pListenerIdentity = listenerIdentity;

            pExceptionThrownHandler = new AsyncExceptionThrownHandler(EmailTransportExceptionEvent_ExceptionThrown);

            if (listenerIdentity.ServiceType != null)
            {
                CreateHost(listenerIdentity.ServiceType);
            }
            else
            {
                CreateHost(typeof(ServiceImplementation));
            }
        }