public override int GetHashCode()
                {
                    int hash = 1;

                    if (Priority != global::Envoy.Api.V3Alpha.Core.RoutingPriority.Default)
                    {
                        hash ^= Priority.GetHashCode();
                    }
                    if (maxConnections_ != null)
                    {
                        hash ^= MaxConnections.GetHashCode();
                    }
                    if (maxPendingRequests_ != null)
                    {
                        hash ^= MaxPendingRequests.GetHashCode();
                    }
                    if (maxRequests_ != null)
                    {
                        hash ^= MaxRequests.GetHashCode();
                    }
                    if (maxRetries_ != null)
                    {
                        hash ^= MaxRetries.GetHashCode();
                    }
                    if (TrackRemaining != false)
                    {
                        hash ^= TrackRemaining.GetHashCode();
                    }
                    if (maxConnectionPools_ != null)
                    {
                        hash ^= MaxConnectionPools.GetHashCode();
                    }
                    if (_unknownFields != null)
                    {
                        hash ^= _unknownFields.GetHashCode();
                    }
                    return(hash);
                }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (MessageProperties != null)
         {
             hashCode = hashCode * 59 + MessageProperties.GetHashCode();
         }
         if (MessageBoxSizeLimit != null)
         {
             hashCode = hashCode * 59 + MessageBoxSizeLimit.GetHashCode();
         }
         if (MessageCountLimit != null)
         {
             hashCode = hashCode * 59 + MessageCountLimit.GetHashCode();
         }
         if (NotifyFailure != null)
         {
             hashCode = hashCode * 59 + NotifyFailure.GetHashCode();
         }
         if (FailureMessageFrom != null)
         {
             hashCode = hashCode * 59 + FailureMessageFrom.GetHashCode();
         }
         if (FailureTemplatePath != null)
         {
             hashCode = hashCode * 59 + FailureTemplatePath.GetHashCode();
         }
         if (MaxRetries != null)
         {
             hashCode = hashCode * 59 + MaxRetries.GetHashCode();
         }
         if (MinWaitBetweenRetries != null)
         {
             hashCode = hashCode * 59 + MinWaitBetweenRetries.GetHashCode();
         }
         if (CountUpdatePoolSize != null)
         {
             hashCode = hashCode * 59 + CountUpdatePoolSize.GetHashCode();
         }
         if (InboxPath != null)
         {
             hashCode = hashCode * 59 + InboxPath.GetHashCode();
         }
         if (SentitemsPath != null)
         {
             hashCode = hashCode * 59 + SentitemsPath.GetHashCode();
         }
         if (SupportAttachments != null)
         {
             hashCode = hashCode * 59 + SupportAttachments.GetHashCode();
         }
         if (SupportGroupMessaging != null)
         {
             hashCode = hashCode * 59 + SupportGroupMessaging.GetHashCode();
         }
         if (MaxTotalRecipients != null)
         {
             hashCode = hashCode * 59 + MaxTotalRecipients.GetHashCode();
         }
         if (BatchSize != null)
         {
             hashCode = hashCode * 59 + BatchSize.GetHashCode();
         }
         if (MaxTotalAttachmentSize != null)
         {
             hashCode = hashCode * 59 + MaxTotalAttachmentSize.GetHashCode();
         }
         if (AttachmentTypeBlacklist != null)
         {
             hashCode = hashCode * 59 + AttachmentTypeBlacklist.GetHashCode();
         }
         if (AllowedAttachmentTypes != null)
         {
             hashCode = hashCode * 59 + AllowedAttachmentTypes.GetHashCode();
         }
         if (ServiceSelector != null)
         {
             hashCode = hashCode * 59 + ServiceSelector.GetHashCode();
         }
         if (FieldWhitelist != null)
         {
             hashCode = hashCode * 59 + FieldWhitelist.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if ComAdobeCqSocialMessagingClientEndpointsImplMessagingOperationProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComAdobeCqSocialMessagingClientEndpointsImplMessagingOperationProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComAdobeCqSocialMessagingClientEndpointsImplMessagingOperationProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     MessageProperties == other.MessageProperties ||
                     MessageProperties != null &&
                     MessageProperties.Equals(other.MessageProperties)
                     ) &&
                 (
                     MessageBoxSizeLimit == other.MessageBoxSizeLimit ||
                     MessageBoxSizeLimit != null &&
                     MessageBoxSizeLimit.Equals(other.MessageBoxSizeLimit)
                 ) &&
                 (
                     MessageCountLimit == other.MessageCountLimit ||
                     MessageCountLimit != null &&
                     MessageCountLimit.Equals(other.MessageCountLimit)
                 ) &&
                 (
                     NotifyFailure == other.NotifyFailure ||
                     NotifyFailure != null &&
                     NotifyFailure.Equals(other.NotifyFailure)
                 ) &&
                 (
                     FailureMessageFrom == other.FailureMessageFrom ||
                     FailureMessageFrom != null &&
                     FailureMessageFrom.Equals(other.FailureMessageFrom)
                 ) &&
                 (
                     FailureTemplatePath == other.FailureTemplatePath ||
                     FailureTemplatePath != null &&
                     FailureTemplatePath.Equals(other.FailureTemplatePath)
                 ) &&
                 (
                     MaxRetries == other.MaxRetries ||
                     MaxRetries != null &&
                     MaxRetries.Equals(other.MaxRetries)
                 ) &&
                 (
                     MinWaitBetweenRetries == other.MinWaitBetweenRetries ||
                     MinWaitBetweenRetries != null &&
                     MinWaitBetweenRetries.Equals(other.MinWaitBetweenRetries)
                 ) &&
                 (
                     CountUpdatePoolSize == other.CountUpdatePoolSize ||
                     CountUpdatePoolSize != null &&
                     CountUpdatePoolSize.Equals(other.CountUpdatePoolSize)
                 ) &&
                 (
                     InboxPath == other.InboxPath ||
                     InboxPath != null &&
                     InboxPath.Equals(other.InboxPath)
                 ) &&
                 (
                     SentitemsPath == other.SentitemsPath ||
                     SentitemsPath != null &&
                     SentitemsPath.Equals(other.SentitemsPath)
                 ) &&
                 (
                     SupportAttachments == other.SupportAttachments ||
                     SupportAttachments != null &&
                     SupportAttachments.Equals(other.SupportAttachments)
                 ) &&
                 (
                     SupportGroupMessaging == other.SupportGroupMessaging ||
                     SupportGroupMessaging != null &&
                     SupportGroupMessaging.Equals(other.SupportGroupMessaging)
                 ) &&
                 (
                     MaxTotalRecipients == other.MaxTotalRecipients ||
                     MaxTotalRecipients != null &&
                     MaxTotalRecipients.Equals(other.MaxTotalRecipients)
                 ) &&
                 (
                     BatchSize == other.BatchSize ||
                     BatchSize != null &&
                     BatchSize.Equals(other.BatchSize)
                 ) &&
                 (
                     MaxTotalAttachmentSize == other.MaxTotalAttachmentSize ||
                     MaxTotalAttachmentSize != null &&
                     MaxTotalAttachmentSize.Equals(other.MaxTotalAttachmentSize)
                 ) &&
                 (
                     AttachmentTypeBlacklist == other.AttachmentTypeBlacklist ||
                     AttachmentTypeBlacklist != null &&
                     AttachmentTypeBlacklist.Equals(other.AttachmentTypeBlacklist)
                 ) &&
                 (
                     AllowedAttachmentTypes == other.AllowedAttachmentTypes ||
                     AllowedAttachmentTypes != null &&
                     AllowedAttachmentTypes.Equals(other.AllowedAttachmentTypes)
                 ) &&
                 (
                     ServiceSelector == other.ServiceSelector ||
                     ServiceSelector != null &&
                     ServiceSelector.Equals(other.ServiceSelector)
                 ) &&
                 (
                     FieldWhitelist == other.FieldWhitelist ||
                     FieldWhitelist != null &&
                     FieldWhitelist.Equals(other.FieldWhitelist)
                 ));
        }
Example #4
0
        /// <summary>
        /// Execute the XML request to the API endpoint
        /// </summary>
        /// <param name="RequestXml"></param>
        /// <returns></returns>
        private async Task <Stream> Execute(Stream RequestXml)
        {
            HttpClient client = new HttpClient(GetHttpMessageHandler());

            client.Timeout = timeout;
            client.DefaultRequestHeaders.UserAgent.ParseAdd(userAgent);

            RequestXml.Position = 0;
            StreamContent content = new StreamContent(RequestXml);

            content.Headers.ContentType = new MediaTypeHeaderValue(RequestContentType);

            for (int attempt = 0; attempt <= MaxRetries; attempt++)
            {
                if (attempt > 0)
                {
                    // Delay this retry based on exponential delay
                    await Task.Delay(ExponentialDelay(attempt));
                }
                HttpResponseMessage response = client.PostAsync(endpointUrl, content).Result;

                int httpCode = (int)response.StatusCode;
                if (response.IsSuccessStatusCode)
                {
                    Stream stream = await response.Content.ReadAsStreamAsync();

                    return(stream);
                }
                else if (Array.Exists(noRetryServerErrorCodes, element => element == httpCode))
                {
                    // Do not retry this explicitly set 500 level server error
                    response.EnsureSuccessStatusCode();
                }
                else if (httpCode >= 500 && httpCode <= 599)
                {
                    // Retry 500 level server errors
                    continue;
                }
                else
                {
                    // Throw exception for non-500 level errors
                    response.EnsureSuccessStatusCode();

                    // Will this also throw for timeouts?  Let's find out!
                }
            }

            throw new HttpRequestException("Request retry count exceeded max retry count: " + MaxRetries.ToString());
        }