コード例 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var esConnection = EventStoreConnection.Create(
                Configuration["eventStore:connectionString"],
                ConnectionSettings.Create().KeepReconnecting(),
                Environment.ApplicationName);
            var store = new EsAggregateStore(esConnection);

            services.AddSingleton(esConnection)
            .AddSingleton <IAggregateStore>(store)
            .AddSingleton <IApplicationService, DailyBudgetsCommandService>()
            .AddControllers();

            var dailybudgetItems = new List <ReadModels.DailyBudgets>();

            services.AddSingleton <IEnumerable <ReadModels.DailyBudgets> >(dailybudgetItems);
            var subscription = new EsSubscription(esConnection, dailybudgetItems);

            services.AddSingleton <IHostedService>(new EventStoreService(esConnection, subscription));
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
            services.AddOpenApiDocument(settings =>
            {
                settings.Title        = "Budgee";
                settings.DocumentName = "v1";
                settings.Version      = "v1";
            });
            //services.AddSwaggerGen(c =>
            //    c.SwaggerDoc("v1",
            //        new Microsoft.OpenApi.Models.OpenApiInfo { Title = "DailyBudgets", Version = "v1" }));
        }
コード例 #2
0
 public EventStoreService(IEventStoreConnection connection,
                          EsSubscription subscription)
 {
     this.connection   = connection;
     this.subscription = subscription;
 }