Aspectacular.AzureQueueMulticastRoute.TransformInboundMessages C# (CSharp) Method

TransformInboundMessages() private method

private TransformInboundMessages ( IList inboundMessages, Stopwatch stopWatch ) : IList
inboundMessages IList
stopWatch Stopwatch
return IList
        private IList<CloudQueueMessage> TransformInboundMessages(IList<CloudQueueMessage> inboundMessages, Stopwatch stopWatch)
        {
            if(this.OptionalThreadSafeMessageTransformer == null)
                return inboundMessages;

            // Transform messages before requeueing them.

            if(inboundMessages.Count < 5)
                // When we have a few messages, transform them sequentially.
                inboundMessages = inboundMessages.Select(msg => this.OptionalThreadSafeMessageTransformer(msg)).ToList();
            else
                // When there are many messages, transform them in parallel.
                inboundMessages = inboundMessages.AsParallel().AsOrdered().Select(msg => this.OptionalThreadSafeMessageTransformer(msg)).ToList();

            this.LogInformation("Done transforming {0} messages. Elapsed {1}.", inboundMessages.Count, stopWatch.Elapsed);
            stopWatch.Reset();
            stopWatch.Start();

            return inboundMessages;
        }