コード例 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSingleton <IEventStoreConnection>(EventStoreConnection.Create(Configuration.GetConnectionString("EventStoreConnection")));

            var inventoryListView = new InventoryListView();
            var inventoryView     = new InventoryItemDetailView();

            services.AddSingleton <IReadOnlyList <InventoryItemListDto> > (inventoryListView.Repository);
            services.AddSingleton <IReadOnlyDictionary <Guid, InventoryItemDetailsDto> >(inventoryView.Repository);
            services.AddTransient <EventProjector>(svc => new EventProjector(inventoryListView, inventoryView, svc.GetRequiredService <ILogger <EventProjector> >()));

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "My API", Version = "v1"
                });
            });
        }
コード例 #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var connectionString = Configuration.GetConnectionString("RedisConnection");

            this.redisMultiplexer = ConnectionMultiplexer.Connect(connectionString);
            //     services.AddTransient<IDatabase>(svc => redisMultiplexer.GetDatabase());

            var inventoryListView = new InventoryListView();
            var inventoryView     = new InventoryItemDetailView();

            services.AddSingleton <IReadOnlyList <InventoryItemListDto> > (inventoryListView.Repository);
            services.AddSingleton <IReadOnlyDictionary <Guid, InventoryItemDetailsDto> >(inventoryView.Repository);
            services.AddTransient <EventProjector>(svc => new EventProjector(inventoryListView, inventoryView, svc.GetRequiredService <ILogger <EventProjector> >()));

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "My API", Version = "v1"
                });
            });
        }
コード例 #3
0
 public EventProjector(InventoryListView inventoryListView, InventoryItemDetailView inventoryView, ILogger <EventProjector> logger)
 {
     this.inventoryListView = inventoryListView;
     this.inventoryView     = inventoryView;
     this.logger            = logger;
 }