Esempio n. 1
0
        /// <summary>
        /// Enables the discovery.
        /// </summary>
        /// <param name="host">The host.</param>
        public static void EnableDiscovery(this ServiceHostBase host)
        {
            var announcementEndpointUrl = ConfigurationHelper.CloudAnnounce;

            if (String.IsNullOrWhiteSpace(announcementEndpointUrl))
            {
                var errorMessage = string.Format(
                    "No value found for key '{0}' in configuration file"
                    + ", please provide a key '{0}' in the section AppConfig and set its value to the appropriate announcement endpoint url",
                    ConfigurationHelper.CloudAnnounce
                    );
                throw new ApplicationException(errorMessage);
            }

            var announcementEndpoint = new AnnouncementEndpoint(
                BindingFactory.CreateBindingFromKey(BindingFactory.Key.WsHttpBindingNoSecurity),
                new EndpointAddress(announcementEndpointUrl));

            var discovery = new ServiceDiscoveryBehavior();

            discovery.AnnouncementEndpoints.Add(announcementEndpoint);
            host.Description.Behaviors.Add(discovery);
        }