/// <summary>
        /// Sets up azure storage command auditing for output to a queue. This is best suited for scenarios
        /// where there are multiple auditors or storage mechanisms in the audit pipeline as it enables
        /// execution of the command dispatch pipeline to rapidly continue but still with a guarantee
        /// that the command will be audited.
        ///
        /// Generally when configuring this auditor no other auditors are configured - but you can.
        /// </summary>
        /// <param name="dependencyResolver">The dependency resolver</param>
        /// <param name="queue">The queue to audit via</param>
        /// <param name="blobContainer">The blob container to store the payload to. If this is set then the
        /// payload is stored before the item is queued, if left null then the payload will be serialized
        /// into the queue item. The default setting of null is the more performant and common case, setting
        /// the container here is only useful for very large command payloads that won't fit inside a queue
        /// item. If the payload is stored in the blob container specified here then there will be no way
        /// for downstream auditors to access it from the AuditItem model - it will be null.
        /// </param>
        /// <param name="storageStrategy"></param>
        /// <returns></returns>
        public static ICommandingDependencyResolverAdapter AddAzureStorageCommandAuditing(this ICommandingDependencyResolverAdapter dependencyResolver,
                                                                                          CloudQueue queue,
                                                                                          CloudBlobContainer blobContainer   = null,
                                                                                          IStorageStrategy storageStrategy   = null,
                                                                                          AzureStorageAuditorOptions options = null)
        {
            options = options ?? new AzureStorageAuditorOptions();
            ICloudAuditQueueProvider cloudAuditQueueProvider = new CloudAuditQueueProvider(queue, null);
            ICloudAuditQueueBlobContainerProvider cloudAuditQueueBlobContainerProvider = new CloudAuditQueueBlobContainerProvider(blobContainer);

            dependencyResolver.RegisterInstance(cloudAuditQueueProvider);
            dependencyResolver.RegisterInstance(cloudAuditQueueBlobContainerProvider);
            dependencyResolver.TypeMapping <IAzureStorageQueueSerializer, AzureStorageQueueSerializer>();
            if (options.UsePreDispatchAuditor)
            {
                EnsureCommandingRuntime(dependencyResolver);
                dependencyResolver.AssociatedCommandingRuntime.AddPreDispatchCommandingAuditor <AzureStorageQueueCommandAuditor>(dependencyResolver, options.AuditPreDispatchRootOnly);
            }
            if (options.UsePostDispatchAuditor)
            {
                EnsureCommandingRuntime(dependencyResolver);
                dependencyResolver.AssociatedCommandingRuntime.AddPostDispatchCommandingAuditor <AzureStorageQueueCommandAuditor>(dependencyResolver, options.AuditPostDispatchRootOnly);
            }
            if (options.UseExecutionAuditor)
            {
                EnsureCommandingRuntime(dependencyResolver);
                dependencyResolver.AssociatedCommandingRuntime.AddExecutionCommandingAuditor <AzureStorageQueueCommandAuditor>(dependencyResolver, options.AuditExecuteDispatchRootOnly);
            }
            return(dependencyResolver);
        }
        /// <summary>
        /// Registers the IAzureStorageCommandQueueProcessorFactory interface through which a audit queue processor task can be
        /// started
        /// </summary>
        /// <param name="dependencyResolver">The dependency resolver</param>
        /// <param name="queue">The queue to dequeue from</param>
        /// <param name="deadLetterQueue">An optional dead letter queue to place items in if errors repeatedly occur in item processing</param>
        /// <returns>The dependency resovler</returns>
        public static ICommandingDependencyResolverAdapter AddAzureStorageAuditQueueProcessor(this ICommandingDependencyResolverAdapter dependencyResolver,
                                                                                              CloudQueue queue, CloudQueue deadLetterQueue = null)
        {
            ICloudAuditQueueProvider cloudAuditQueueProvider = new CloudAuditQueueProvider(queue, deadLetterQueue);

            dependencyResolver.RegisterInstance(cloudAuditQueueProvider);
            dependencyResolver.TypeMapping <IAzureStorageQueueSerializer, AzureStorageQueueSerializer>();
            dependencyResolver.TypeMapping <IAzureStorageAuditQueueProcessorFactory, AzureStorageAuditQueueProcessorFactory>();
            return(dependencyResolver);
        }