private void HostExposedService(IBackendServiceLocation serviceLocation)
        {
            // Configure the ServiceHost to be a Per-Session service.
            ServiceHost host = new ServiceHost(serviceLocation.ServiceType);

            Binding         binding  = ServiceBindingCache.GetBindingForContractType(serviceLocation.ContractType);
            EndpointAddress address  = ServiceFactory.GetEndpointAddress(serviceLocation.ContractType, binding);
            ServiceEndpoint endpoint = host.AddServiceEndpoint(serviceLocation.ContractType, binding, address.Uri);

            _hostedExposedServices.Add(host);

            host.Open();
        }
        private void HostAllServices()
        {
            foreach (IBackendServiceLocation serviceLocation in ServiceBindingCache.GetServiceLocations())
            {
                Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.SvcMgrServiceHosting, serviceLocation.Name);
                try
                {
                    Stopwatch sw = Stopwatch.StartNew();

                    HostService(serviceLocation);

                    sw.Stop();
                    Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.SvcMgrServiceHosted, sw.ElapsedMilliseconds);
                }
                catch (Exception exception)
                {
                    Logger.Instance.LogException(this, exception);
                    Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.SvcMgrServiceHostingError);
                }
            }
        }
        private void HostExposedService(IBackendServiceLocation serviceLocation)
        {
            string path     = ServiceFactory.BackendConfigurator.Get("Certificate");
            string password = ServiceFactory.BackendConfigurator.Get("Certificate.Password");
            // Configure the ServiceHost to be a Per-Session service.
            ServiceHost host = new ServiceHost(serviceLocation.ServiceType);

            if (File.Exists(path))
            {
                X509Certificate2 certificate = new X509Certificate2(path, password);
                host.Credentials.ServiceCertificate.Certificate = certificate;
                host.Credentials.ClientCertificate.Authentication.CertificateValidationMode  = X509CertificateValidationMode.Custom;
                host.Credentials.ClientCertificate.Authentication.CustomCertificateValidator = new CertificateValidator(certificate.Thumbprint);
            }

            Binding         binding  = ServiceBindingCache.GetBindingForContractType(serviceLocation.ContractType);
            EndpointAddress address  = ServiceFactory.GetEndpointAddress(serviceLocation.ContractType, binding);
            ServiceEndpoint endpoint = host.AddServiceEndpoint(serviceLocation.ContractType, binding, address.Uri);

            _hostedExposedServices.Add(host);

            host.Open();
        }