コード例 #1
0
        private static async Task <ICommandDispatcher> ConfigureEnqueue()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            CloudQueue          auditQueue     = storageAccount.CreateCloudQueueClient().GetQueueReference("auditqueue");
            await auditQueue.CreateIfNotExistsAsync();

            IServiceCollection            serviceCollection  = new ServiceCollection();
            ICommandingDependencyResolver dependencyResolver = serviceCollection.GetCommandingDependencyResolver(() => _serviceProvider);

            IReadOnlyDictionary <string, object> Enricher(IReadOnlyDictionary <string, object> existing) => new Dictionary <string, object>
            {
                { "ExampleEnrichedCounter", Interlocked.Increment(ref _counter) }
            };
            Options options = new Options
            {
                Reset     = true, // we reset the registry because we allow repeat runs, in a normal app this isn't required
                Enrichers = new[] { new FunctionWrapperCommandDispatchContextEnricher(Enricher) }
            };

            dependencyResolver.UseCommanding(options)
            .Register <ChainCommandHandler>()
            .Register <OutputWorldToConsoleCommandHandler>();
            dependencyResolver.UseAzureStorageCommandAuditing(auditQueue);
            _serviceProvider = serviceCollection.BuildServiceProvider();
            return(_serviceProvider.GetService <ICommandDispatcher>());
        }
コード例 #2
0
        private static async Task <IAzureStorageAuditQueueProcessorFactory> ConfigureDequeue(IStorageStrategy storageStrategy)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            CloudQueue          auditQueue     = storageAccount.CreateCloudQueueClient().GetQueueReference("auditqueue");
            await auditQueue.CreateIfNotExistsAsync();

            IServiceCollection            serviceCollection = new ServiceCollection();
            ICommandingDependencyResolver resolver          = serviceCollection.GetCommandingDependencyResolver(() => _serviceProvider);
            Options options = new Options
            {
                Reset = true // we reset the registry because we allow repeat runs, in a normal app this isn't required
            };

            resolver.UseCommanding(options);
            resolver.UseQueues();
            resolver.UseAzureStorageCommandAuditing(storageAccount, storageStrategy: storageStrategy); // this sets up the table store auditors
            resolver.UseAzureStorageAuditQueueProcessor(auditQueue);                                   // this sets up queue listening
            _serviceProvider = serviceCollection.BuildServiceProvider();

            return(_serviceProvider.GetService <IAzureStorageAuditQueueProcessorFactory>());
        }
コード例 #3
0
        private static ICommandDispatcher Configure()
        {
            IServiceCollection            serviceCollection  = new ServiceCollection();
            ICommandingDependencyResolver dependencyResolver = serviceCollection.GetCommandingDependencyResolver(() => _serviceProvider);

            IReadOnlyDictionary <string, object> Enricher(IReadOnlyDictionary <string, object> existing) => new Dictionary <string, object>
            {
                { "ExampleEnrichedCounter", Interlocked.Increment(ref _counter) }
            };
            Options options = new Options
            {
                Reset     = true, // we reset the registry because we allow repeat runs, in a normal app this isn't required
                Enrichers = new[] { new FunctionWrapperCommandDispatchContextEnricher(Enricher) }
            };

            dependencyResolver.UseCommanding(options)
            .Register <ChainCommandHandler>()
            .Register <OutputWorldToConsoleCommandHandler>();
            dependencyResolver.UseEventHubCommandAuditing(EventHubConnectionString, EventHubName);
            _serviceProvider = serviceCollection.BuildServiceProvider();
            return(_serviceProvider.GetService <ICommandDispatcher>());
        }