Example #1
0
 /// <summary>
 /// Build a Builder to help you generate an immutable ClientConfig using the
 /// the default value for ClientTimeout, MaxResponseContentBufferSize and CompressionEnabled
 ///
 /// Usage:
 /// <code>
 ///  var builder = new ClientConfig.Builder();
 ///  builder.Hostname = ClientConfig.Environments.Sandbox;
 ///  builder.ConsumerKey = "KEY";
 ///  builder.ConsumerSecret = "SECRET";
 ///  var config = builder.build();
 /// </code>
 /// </summary>
 public Builder()
 {
     ClientTimeout = DefaultTimeout;
     MaxResponseContentBufferSize = DefaultMaxResponseContentBufferSize;
     CompressionEnabled           = DefaultCompressionEnabled;
     ExponentialBackoffConfig     = DefaultExponentialBackoffConfig;
 }
Example #2
0
        private ClientConfig(
            string hostname,
            string consumerKey,
            string consumerSecret,
            string token,
            int clientTimeout,
            long maxResponseContentBufferSize,
            bool compressionEnabled,
            IExponentialBackoffConfig exponentialBackoffConfig)
        {
            if (string.IsNullOrEmpty(token))
            {
                if (string.IsNullOrEmpty(consumerKey))
                {
                    throw new ArgumentException("securityConsumerKey property cannot be blank.");
                }

                if (string.IsNullOrEmpty(consumerSecret))
                {
                    throw new ArgumentException("securityConsumerSecret property cannot be blank.");
                }
            }

            if (clientTimeout < 0)
            {
                throw new ArgumentException("clientTimeout must be a positive number.");
            }

            if (maxResponseContentBufferSize < 0)
            {
                throw new ArgumentException("maxResponseContentBufferSize must be a positive number.");
            }

            Hostname       = hostname;
            ConsumerKey    = consumerKey;
            ConsumerSecret = consumerSecret;
            Token          = token;
            ClientTimeout  = clientTimeout;
            MaxResponseContentBufferSize = maxResponseContentBufferSize;
            CompressionEnabled           = compressionEnabled;
            ExponentialBackoffConfig     = exponentialBackoffConfig;
        }