public ServiceBrokerTransportReceiver(ServiceBrokerServiceBusReceiverConfiguration receiverConfiguration, ServiceBrokerServiceBusConfiguration configuration)
 {
     messageMapper = configuration.MessageMapper;
     messageEncoder = configuration.MessageEncoder;
     ServiceBrokerMessageType = configuration.ServiceBrokerMessageType;
     if (string.IsNullOrWhiteSpace(ServiceBrokerMessageType))
     {
         throw new InvalidConfigurationException("ServiceBrokerMessageType cannot be null or whitespace.");
     }
     ServiceBrokerContract = configuration.ServiceBrokerContract;
     if (string.IsNullOrWhiteSpace(ServiceBrokerContract))
     {
         throw new InvalidConfigurationException("ServiceBrokerContract cannot be null or whitespace.");
     }
     ServiceBrokerService = receiverConfiguration.ServiceBrokerService;
     if (string.IsNullOrWhiteSpace(ServiceBrokerService))
     {
         throw new InvalidConfigurationException("ServiceBrokerService cannot be null or whitespace.");
     }
     ServiceBrokerQueue = receiverConfiguration.ServiceBrokerQueue;
     if (string.IsNullOrWhiteSpace(ServiceBrokerQueue))
     {
         throw new InvalidConfigurationException("ServiceBrokerQueue cannot be null or whitespace.");
     }
     ConnectionString = configuration.ServiceBrokerConnectionString;
     if (string.IsNullOrWhiteSpace(ConnectionString) &&
         !string.IsNullOrWhiteSpace(configuration.ServiceBrokerConnectionStringName) &&
         ConfigurationManager.ConnectionStrings[configuration.ServiceBrokerConnectionStringName] != null)
     {
         ConnectionString = ConfigurationManager.ConnectionStrings[configuration.ServiceBrokerConnectionStringName].ConnectionString;
     }
     if (string.IsNullOrWhiteSpace(ConnectionString))
     {
         throw new InvalidConfigurationException("ServiceBrokerConnectionString cannot be null or whitespace.");
     }
     MaxRetries = receiverConfiguration.MaxRetries;
     if (MaxRetries < 0)
     {
         MaxRetries = 0;
     }
     MaxConcurrency = receiverConfiguration.MaxConcurrency;
     if (MaxConcurrency < 0)
     {
         MaxConcurrency = 0;
     }
     if (MaxConcurrency > 0)
     {
         workerThreadPool = new Semaphore(MaxConcurrency, MaxConcurrency);
     }
     faultManager = new TransportMessageFaultManager(MaxRetries);
 }
 public ServiceBrokerTransportSender(ServiceBrokerServiceBusConfiguration configuration)
 {
     ServiceBrokerMessageType = configuration.ServiceBrokerMessageType;
     if (string.IsNullOrWhiteSpace(ServiceBrokerMessageType))
     {
         throw new InvalidConfigurationException("ServiceBrokerMessageType cannot be null or whitespace.");
     }
     ServiceBrokerContract = configuration.ServiceBrokerContract;
     if (string.IsNullOrWhiteSpace(ServiceBrokerContract))
     {
         throw new InvalidConfigurationException("ServiceBrokerContract cannot be null or whitespace.");
     }
     ServiceBrokerSendingService = configuration.ServiceBrokerSendingService;
     if (string.IsNullOrWhiteSpace(ServiceBrokerSendingService))
     {
         throw new InvalidConfigurationException("ServiceBrokerSendingService cannot be null or whitespace.");
     }
     ConnectionString = configuration.ServiceBrokerConnectionString;
     if (string.IsNullOrWhiteSpace(ConnectionString) &&
         !string.IsNullOrWhiteSpace(configuration.ServiceBrokerConnectionStringName) &&
         ConfigurationManager.ConnectionStrings[configuration.ServiceBrokerConnectionStringName] != null)
     {
         ConnectionString = ConfigurationManager.ConnectionStrings[configuration.ServiceBrokerConnectionStringName].ConnectionString;
     }
     if (string.IsNullOrWhiteSpace(ConnectionString))
     {
         throw new InvalidConfigurationException("ServiceBrokerConnectionString cannot be null or whitespace.");
     }
     messageEncoder = configuration.MessageEncoder;
     if (messageEncoder == null)
     {
         throw new InvalidConfigurationException("MessageEncoder cannot be null.");
     }
     messageMapper = configuration.MessageMapper;
     if (messageMapper == null)
     {
         throw new InvalidConfigurationException("MessageMapper cannot be null.");
     }
 }