/// <summary>
        /// Completes all.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="messages">The messages.</param>
        /// <returns>System.Threading.Tasks.Task.</returns>
        public async Task CompleteAll <T>(IEnumerable <T> messages) where T : class
        {
            var ackIds = new List <string>();

            foreach (var message in messages)
            {
                // Safe-guard against nulls.
                if (message == null)
                {
                    break;
                }

                // Find the message, remove from dictionary and grab acknowledge id if existed.
                if (Messages.TryRemove(message, out var foundMsg))
                {
                    ackIds.Add(foundMsg.AckId);
                }
                else
                {
                    // As the message wasn't found using the message as key, this conversion try's to picks up messages of type
                    // IMessageEntity because in their case it's their body that is used for the key in the dictionary.
                    var isEntity = TryGetMessageEntityBody(message, out var msgBody);

                    if (isEntity && Messages.TryRemove(msgBody, out foundMsg))
                    {
                        ackIds.Add(foundMsg.AckId);
                    }
                }
            }

            if (ackIds.Any())
            {
                // Acknowledge message and remove from subscription.
                await ManagementClient.AcknowledgeAsync(new AcknowledgeRequest { AckIds = { ackIds }, Subscription = new SubscriptionName(Config.ProjectId, Config.ReceiverConfig.EntitySubscriptionName).ToString() });
            }
        }