/// <summary>
        /// Creates a <see cref="ServiceConsumer" /> from a factory method that returns a communication object / channel / Visual Studio Service Reference ServiceClient.
        /// </summary>
        /// <typeparam name="TServiceInterface">The type of the service interface.</typeparam>
        /// <param name="endpointConfigurationName">Name of the endpoint configuration.</param>
        /// <param name="retryPolicy">The retry policy.</param>
        /// <param name="exceptionStrategy">The exception strategy.</param>
        /// <param name="closeTriggerStrategy">The service channel close trigger strategy.</param>
        /// <returns>
        /// A <see cref="ServiceConsumer" />.
        /// </returns>
        public static IServiceConsumer <TServiceInterface> Create <TServiceInterface>(string endpointConfigurationName, IRetryPolicyFunction retryPolicy, IServiceConsumerExceptionBehaviourStrategy exceptionStrategy, IServiceChannelCloseTriggerStrategy closeTriggerStrategy)
        {
            Func <ICommunicationObject> factoryMethod = () => ServiceChannelFactory.CreateChannel <TServiceInterface>(endpointConfigurationName);

            return(ServiceConsumerFactory.Create <TServiceInterface>(factoryMethod, retryPolicy, exceptionStrategy, closeTriggerStrategy));
        }
        private static IServiceConsumer <TServiceInterface> CreateServiceConsumer <TServiceInterface>(Func <ICommunicationObject> factoryMethod, IRetryPolicyFunction retryPolicy, IServiceConsumerExceptionBehaviourStrategy exceptionStrategy, IServiceChannelCloseTriggerStrategy closeTriggerStrategy)
        {
            var consumer = new ServiceConsumer <TServiceInterface>(factoryMethod);

            consumer.ExceptionBehaviourStrategy = exceptionStrategy;
            consumer.RetryPolicy = retryPolicy;
            consumer.ChannelCloseTriggerStrategy = closeTriggerStrategy;
            return(consumer);
        }
 /// <summary>
 /// Creates a <see cref="ServiceConsumer" /> from a factory method that returns a communication object / channel / Visual Studio Service Reference ServiceClient.
 /// </summary>
 /// <typeparam name="TServiceInterface">The type of the service interface.</typeparam>
 /// <param name="factoryMethod">The factory method.</param>
 /// <param name="retryPolicy">The retry policy.</param>
 /// <param name="exceptionStrategy">The exception strategy.</param>
 /// <param name="closeTriggerStrategy">The service channel close trigger strategy.</param>
 /// <returns>
 /// A <see cref="ServiceConsumer" />.
 /// </returns>
 public static IServiceConsumer <TServiceInterface> Create <TServiceInterface>(Func <ICommunicationObject> factoryMethod, IRetryPolicyFunction retryPolicy, IServiceConsumerExceptionBehaviourStrategy exceptionStrategy, IServiceChannelCloseTriggerStrategy closeTriggerStrategy)
 {
     return(CreateServiceConsumer <TServiceInterface>(factoryMethod, retryPolicy, exceptionStrategy, closeTriggerStrategy));
 }