예제 #1
0
        public IEventStoreCqrsBuilder AddProjectionJob <TProjection>(
            string name,
            Action <IProjectionBuilder>?configure = default)
            where TProjection : class, IProjection
        {
            builder.Services.AddHostedService <ProjectionJob <TProjection> >();
            builder.Services.AddSingleton <IProjectionProcessor <TProjection>, ProjectionProcessor <TProjection> >();
            builder.Services.AddTransient <TProjection>();

            var projectionBuilder = new ProjectionBuilder(name);

            configure?.Invoke(projectionBuilder);

            SetFiltersFromProjection <TProjection>(projectionBuilder);

            builder
            .Services
            .Configure <ProjectionOptions>(
                typeof(TProjection).Name,
                options => projectionBuilder.Build(options));

            return(this);
        }