Ejemplo n.º 1
0
        private ChannelFactory <T> GetChannelFactory(Action <ChannelFactory <T> > modifyChannelFactory = null, Action <System.ServiceModel.Channels.Binding> modifyBinding = null)
        {
            System.ServiceModel.Channels.Binding binding = Binding.GetDefaultBinding();

            if (modifyBinding != null)
            {
                modifyBinding(binding);
            }

            ChannelFactory <T> channelFactory = new ChannelFactory <T>(binding);
            ServiceBehavior    behavior       = new ServiceBehavior(Transport.Protocol, Transport.EnableSsl);

            behavior.SetBehavior(channelFactory);

            if (modifyChannelFactory != null)
            {
                modifyChannelFactory(channelFactory);
            }

            if (EnableLogging)
            {
                channelFactory.Endpoint.Behaviors.Add(new LogMessageBehavior());
            }

            return(channelFactory);
        }