示例#1
0
 public static IConveyBuilder AddApplication(this IConveyBuilder builder)
 {
     return(builder.AddCommandHandlers()
            .AddEventHandlers()
            .AddInMemoryCommandDispatcher()
            .AddInMemoryEventDispatcher());
 }
        public static IConveyBuilder AddInfrastructure(this IConveyBuilder builder)
        {
            builder.Services
            .AddSingleton <IHttpContextAccessor, HttpContextAccessor>()
            .AddTransient <IStorage, RedisStorage>();

            builder
            .AddCommandHandlers()
            .AddEventHandlers()
            .AddInMemoryCommandDispatcher()
            .AddInMemoryEventDispatcher()
            .AddQueryHandlers()
            .AddInMemoryQueryDispatcher()
            .AddJwt()
            .AddHttpClient()
            .AddConsul()
            .AddFabio()
            .AddRabbitMq(plugins: p => p.AddJaegerRabbitMqPlugin())
            .AddRedis()
            .AddPrometheus()
            .AddJaeger()
            .AddWebApiSwaggerDocs()
            .AddSecurity();

            builder.Services.AddScoped <LogContextMiddleware>()
            .AddSingleton <ICorrelationIdFactory, CorrelationIdFactory>();

            builder.Services.TryDecorate(typeof(ICommandHandler <>), typeof(LoggingCommandHandlerDecorator <>));
            builder.Services.TryDecorate(typeof(IEventHandler <>), typeof(LoggingEventHandlerDecorator <>));

            return(builder);
        }
示例#3
0
        public static IConveyBuilder AddCore(this IConveyBuilder builder)
        {
            builder.Services
            .AddScoped <LogContextMiddleware>()
            .AddChronicle()
            .AddScoped <IAdApiClient, AdApiHttpClient>()
            .AddScoped <IMessageBroker, MessageBroker>();

            builder
            .AddCommandHandlers()
            .AddEventHandlers()
            .AddInMemoryCommandDispatcher()
            .AddInMemoryEventDispatcher()
            .AddQueryHandlers()
            .AddInMemoryQueryDispatcher()
            .AddHttpClient()
            .AddRabbitMq()
            .AddMessageOutbox(o => o.AddMongo())
            .AddMongo()
            .AddRedis()
            .AddPrometheus()
            .AddJaeger()
            .AddJwt();

            builder.Services.TryDecorate(typeof(ICommandHandler <>), typeof(LoggingCommandHandlerDecorator <>));
            builder.Services.TryDecorate(typeof(IEventHandler <>), typeof(LoggingEventHandlerDecorator <>));
            builder.Services.TryDecorate(typeof(ICommandHandler <>), typeof(OutboxCommandHandlerDecorator <>));
            builder.Services.TryDecorate(typeof(IEventHandler <>), typeof(OutboxEventHandlerDecorator <>));

            return(builder);
        }
示例#4
0
 public static IConveyBuilder AddApplication(this IConveyBuilder builder)
 => builder
 .AddCommandHandlers()
 .AddEventHandlers()
 .AddQueryHandlers()
 .AddInMemoryCommandDispatcher()
 .AddInMemoryEventDispatcher()
 .AddInMemoryQueryDispatcher();
        public static IConveyBuilder AddApplication(this IConveyBuilder builder)
        {
            builder.Services.AddTransient <IHistoryService, HistoryService>();

            return(builder
                   .AddCommandHandlers()
                   .AddEventHandlers()
                   .AddInMemoryCommandDispatcher()
                   .AddInMemoryEventDispatcher());
        }
示例#6
0
        public static IConveyBuilder AddApplication(this IConveyBuilder builder)
        {
            builder
            .AddCommandHandlers()
            .AddInMemoryCommandDispatcher()
            .AddQueryHandlers()
            .AddInMemoryQueryDispatcher();

            return(builder);
        }
        public static IConveyBuilder AddApplication(this IConveyBuilder builder)
        {
            builder.Services
            .AddSingleton <IStoryTextPolicy, DefaultStoryTextPolicy>();

            return(builder
                   .AddCommandHandlers()
                   .AddEventHandlers()
                   .AddInMemoryCommandDispatcher()
                   .AddInMemoryEventDispatcher());
        }
示例#8
0
        public static IConveyBuilder AddApplication(this IConveyBuilder builder)
        {
            builder.Services.AddTransient <ISchedulePolicy, SchedulePolicy>();

            return(builder
                   .AddCommandHandlers()
                   .AddEventHandlers()
                   .AddQueryHandlers()
                   .AddInMemoryCommandDispatcher()
                   .AddInMemoryEventDispatcher()
                   .AddInMemoryQueryDispatcher());
        }
示例#9
0
        public static IConveyBuilder AddApplication(this IConveyBuilder builder)
        {
            builder
            .AddCommandHandlers()
            .AddEventHandlers()
            .AddInMemoryCommandDispatcher()
            .AddInMemoryEventDispatcher();

            builder.Services.AddSingleton <IParcelsService>(new ParcelsService());

            return(builder);
        }
        public static IConveyBuilder AddCore(this IConveyBuilder builder)
        {
            builder
                .AddCommandHandlers()
                .AddEventHandlers()
                .AddInMemoryCommandDispatcher()
                .AddInMemoryEventDispatcher()
                .AddQueryHandlers()
                .AddInMemoryQueryDispatcher();

            return builder;
        }
示例#11
0
        public static IConveyBuilder AddApplication(this IConveyBuilder builder)
        {
            builder.Services
            .AddSingleton <IEventMapper, EventMapper>()
            .AddScoped <IStoryRatingService, StoryRatingService>()
            .AddSingleton <IStoryTextFactory, StoryTextFactory>()
            .AddSingleton <IStoryAuthorPolicy, StoryAuthorPolicy>();

            return(builder
                   .AddCommandHandlers()
                   .AddEventHandlers()
                   .AddInMemoryCommandDispatcher()
                   .AddInMemoryEventDispatcher());
        }
        public static IConveyBuilder AddCore(this IConveyBuilder builder)
        {
            builder.Services
            .AddScoped <IMessageBroker, MessageBroker>()
            .AddSingleton <IHttpContextAccessor, HttpContextAccessor>()
            .AddScoped <IStoriesService, StoriesService>()
            .AddScoped <ITagsService, TagsService>()
            .AddScoped <ITrendingService, TrendingService>()
            .AddScoped <IUsersService, UsersService>()
            .AddScoped <IDatabaseProvider, DatabaseProvider>();

            builder
            .AddCommandHandlers()
            .AddEventHandlers()
            .AddInMemoryCommandDispatcher()
            .AddInMemoryEventDispatcher()
            .AddQueryHandlers()
            .AddInMemoryQueryDispatcher()
            .AddJwt()
            .AddHttpClient()
            .AddConsul()
            .AddFabio()
            .AddRabbitMq(plugins: p => p.AddJaegerRabbitMqPlugin())
            .AddMessageOutbox(o => o.AddMongo())
            .AddMongo()
            .AddRedis()
            .AddPrometheus()
            .AddJaeger()
            .AddWebApiSwaggerDocs()
            .AddSecurity();

            builder.Services.AddScoped <LogContextMiddleware>()
            .AddSingleton <ICorrelationIdFactory, CorrelationIdFactory>();

            builder.Services.TryDecorate(typeof(ICommandHandler <>), typeof(LoggingCommandHandlerDecorator <>));
            builder.Services.TryDecorate(typeof(IEventHandler <>), typeof(LoggingEventHandlerDecorator <>));
            builder.Services.TryDecorate(typeof(ICommandHandler <>), typeof(OutboxCommandHandlerDecorator <>));
            builder.Services.TryDecorate(typeof(IEventHandler <>), typeof(OutboxEventHandlerDecorator <>));

            return(builder);
        }
示例#13
0
        public static IConveyBuilder AddIdentityModule(this IConveyBuilder builder)
        {
            var options = builder.GetOptions <IdentityOptions>("identity");

            builder.Services.AddSingleton(options);
            builder.Services.AddTransient <IAuthTokensService, AuthTokensService>();
            builder.Services.AddTransient <IRefreshTokensService, RefreshTokensService>();
            builder.Services.AddSingleton <IPasswordsService, PasswordService>();
            builder.Services.AddTransient <JwtAuthorizationMiddleware>();
            builder.Services.AddTransient <IAuthTokensCache, AuthTokensCache>();
            builder.Services.AddTransient <ISignUpValidator, SignUpValidator>();
            builder.Services.AddMemoryCache();

            builder.Services.AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                o.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(o =>
            {
                o.RequireHttpsMetadata      = false;
                o.SaveToken                 = true;
                o.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(options.Key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            return(builder
                   .AddCommandHandlers()
                   .AddQueryHandlers()
                   .AddInMemoryCommandDispatcher()
                   .AddInMemoryQueryDispatcher()
                   .AddMongo()
                   .AddMongoRepository <IdentityDocument, Guid>("users")
                   .AddMongoRepository <RefreshTokenDocument, Guid>("refresh_token"));
        }