Пример #1
0
        protected virtual ServiceHost CreateAndConfigureServiceHost <T>(T serviceInstance, Uri baseAddress, bool isDuplex = false)
        {
            var serviceHost     = new ServiceHost(serviceInstance, baseAddress);
            var serviceEndPoint = serviceHost.AddServiceEndpoint(typeof(T), ClientServerBindingHelper.GetBinding(isDuplex), string.Empty);

            serviceEndPoint.Behaviors.Add(new SciendoAuditBehavior());

            return(serviceHost);
        }
Пример #2
0
        protected virtual ServiceHost CreateAndConfigureDiscoverableServiceHost <T>(T serviceInstance, Uri baseAddress, bool isDuplex = false)
        {
            var serviceHost     = new ServiceHost(serviceInstance, baseAddress);
            var serviceEndPoint = serviceHost.AddServiceEndpoint(typeof(T), ClientServerBindingHelper.GetBinding(isDuplex), string.Empty);

            serviceEndPoint.Behaviors.Add(new SciendoAuditBehavior());

            // ** DISCOVERY ** //
            // make the service discoverable by adding the discovery behavior
            ServiceDiscoveryBehavior serviceDiscoveryBehavior = new ServiceDiscoveryBehavior();

            serviceHost.Description.Behaviors.Add(serviceDiscoveryBehavior);

            // send announcements on UDP multicast transport
            serviceDiscoveryBehavior.AnnouncementEndpoints.Add(
                new UdpAnnouncementEndpoint());

            // ** DISCOVERY ** //
            // add the discovery endpoint that specifies where to publish the services
            serviceHost.AddServiceEndpoint(new UdpDiscoveryEndpoint());

            return(serviceHost);
        }