public static ICommandingDependencyResolver UseAzureStorageCommandAuditing(this ICommandingDependencyResolver 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.UsePreDispatchCommandingAuditor <AzureStorageQueueCommandAuditor>(dependencyResolver, options.AuditPreDispatchRootOnly); } if (options.UsePostDispatchAuditor) { EnsureCommandingRuntime(dependencyResolver); dependencyResolver.AssociatedCommandingRuntime.UsePostDispatchCommandingAuditor <AzureStorageQueueCommandAuditor>(dependencyResolver, options.AuditPostDispatchRootOnly); } if (options.UseExecutionAuditor) { EnsureCommandingRuntime(dependencyResolver); dependencyResolver.AssociatedCommandingRuntime.UseExecutionCommandingAuditor <AzureStorageQueueCommandAuditor>(dependencyResolver, options.AuditExecuteDispatchRootOnly); } return(dependencyResolver); }
public static ICommandingDependencyResolver UseAzureStorageCommandAuditing(this ICommandingDependencyResolver dependencyResolver, CloudStorageAccount cloudStorageAccount, CloudBlobContainer commandPayloadContainer = null, IStorageStrategy storageStrategy = null, AzureStorageAuditorOptions options = null) { options = options ?? new AzureStorageAuditorOptions(); if (!options.UseExecutionAuditor && !options.UsePostDispatchAuditor && !options.UsePreDispatchAuditor) { throw new AzureStorageConfigurationException("At least one auditor type must be configured"); } CloudTableClient cloudTableClient = cloudStorageAccount.CreateCloudTableClient(); if (commandPayloadContainer == null) { commandPayloadContainer = cloudStorageAccount.CreateCloudBlobClient().GetContainerReference("commandauditpayload"); } if (storageStrategy == null) { storageStrategy = new SingleTableStrategy(); } ICloudStorageProvider cloudStorageProvider = new CloudStorageProvider(cloudTableClient, commandPayloadContainer); dependencyResolver.RegisterInstance(cloudStorageProvider); dependencyResolver.RegisterInstance(storageStrategy); if (options.UsePreDispatchAuditor) { EnsureCommandingRuntime(dependencyResolver); dependencyResolver.AssociatedCommandingRuntime.UsePreDispatchCommandingAuditor <AzureStorageTableCommandAuditor>(dependencyResolver, options.AuditPreDispatchRootOnly); } if (options.UsePostDispatchAuditor) { EnsureCommandingRuntime(dependencyResolver); dependencyResolver.AssociatedCommandingRuntime.UsePostDispatchCommandingAuditor <AzureStorageTableCommandAuditor>(dependencyResolver, options.AuditPostDispatchRootOnly); } if (options.UseExecutionAuditor) { EnsureCommandingRuntime(dependencyResolver); dependencyResolver.AssociatedCommandingRuntime.UseExecutionCommandingAuditor <AzureStorageTableCommandAuditor>(dependencyResolver, options.AuditExecuteDispatchRootOnly); } return(dependencyResolver); }