Ejemplo n.º 1
0
        /// <summary>
        /// Creates the reusable disco client.
        /// </summary>
        /// <returns></returns>
        public static IDisco CreateReusableDiscoClient(string cfg = null)
        {
            if (String.IsNullOrWhiteSpace(cfg))
            {
                cfg = ConfigurationHelper.DiscoEndpoint;
            }
            var address = new EndpointAddress(cfg);
            var uri     = new Uri(cfg);

            if (uri.Scheme == Uri.UriSchemeNetPipe)
            {
                return(WCFClientProxy <IDisco> .GetReusableInstance(
                           BindingFactory.CreateBindingFromKey(BindingFactory.Key.NetNamedPipeBinding),
                           address));
            }
            else if (uri.Scheme == Uri.UriSchemeHttp)
            {
                return(WCFClientProxy <IDisco> .GetReusableInstance(
                           BindingFactory.CreateBindingFromKey(BindingFactory.Key.BasicHttpBindingNoSecurity),
                           address));
            }
            else if (uri.Scheme == Uri.UriSchemeHttps)
            {
                return(WCFClientProxy <IDisco> .GetReusableInstance(
                           BindingFactory.CreateBindingFromKey(BindingFactory.Key.BasicHttpBindingTransportSecurity),
                           address));
            }
            else
            {
                return(WCFClientProxy <IDisco> .GetReusableInstance(cfg));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the secure endpoints.
        /// </summary>
        public void AddSecureEndpoints()
        {
            var contracts = SentryHostHelper.GetServiceContracts(_serviceType);
            var bnd       = BindingFactory.CreateBindingFromKey(BindingFactory.Key.WsHttpBindingTransportSecurity);

            foreach (var contract in contracts)
            {
                AddServiceEndpoint(contract, bnd, "");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the endpoints.
        /// </summary>
        /// <param name="serviceHost">The service host.</param>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="bindingFactoryKey">The binding factory key.</param>
        public static void AddEndpoints(this ServiceHostBase serviceHost, Type serviceType, string bindingFactoryKey)
        {
            var contracts = GetServiceContracts(serviceType);
            var bnd       = BindingFactory.CreateBindingFromKey(bindingFactoryKey);

            foreach (var s in contracts.Select(contract => contract.ToString()))
            {
                serviceHost.AddServiceEndpoint(s, bnd, "");
            }
        }
Ejemplo n.º 4
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);
        }