init
This commit is contained in:
commit
ab2e20f7e1
72 changed files with 2000 additions and 0 deletions
66
Femto.Modules.Media/MediaModule.cs
Normal file
66
Femto.Modules.Media/MediaModule.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using Femto.Modules.Media.Data;
|
||||
using Femto.Modules.Media.Infrastructure.Integration;
|
||||
using Femto.Modules.Media.Infrastructure.PipelineBehaviours;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Femto.Modules.Media;
|
||||
|
||||
public static class MediaModule
|
||||
{
|
||||
public static void UseBlogModule(this IServiceCollection services, string connectionString)
|
||||
{
|
||||
OutboxMessageTypeRegistry.RegisterOutboxMessageTypesInAssembly(typeof(MediaModule).Assembly);
|
||||
|
||||
services.AddDbContext<MediaContext>(builder =>
|
||||
{
|
||||
builder.UseNpgsql(
|
||||
connectionString,
|
||||
o =>
|
||||
{
|
||||
o.MapEnum<OutboxEntryStatus>("outbox_status");
|
||||
}
|
||||
);
|
||||
;
|
||||
builder.UseSnakeCaseNamingConvention();
|
||||
|
||||
var loggerFactory = LoggerFactory.Create(b =>
|
||||
{
|
||||
b.AddConsole();
|
||||
// .AddFilter(
|
||||
// (category, level) =>
|
||||
// category == DbLoggerCategory.Database.Command.Name
|
||||
// && level == LogLevel.Debug
|
||||
// );
|
||||
});
|
||||
|
||||
builder.UseLoggerFactory(loggerFactory);
|
||||
builder.EnableSensitiveDataLogging();
|
||||
});
|
||||
|
||||
services.AddMediatR(c =>
|
||||
{
|
||||
c.RegisterServicesFromAssembly(typeof(MediaModule).Assembly);
|
||||
});
|
||||
|
||||
services.SetupMediatrPipeline();
|
||||
|
||||
services.AddTransient<Outbox, Outbox>();
|
||||
services.AddHostedService<Mailman>();
|
||||
}
|
||||
|
||||
private static void SetupMediatrPipeline(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient(
|
||||
typeof(IPipelineBehavior<,>),
|
||||
typeof(DomainEventsPipelineBehaviour<,>)
|
||||
);
|
||||
|
||||
services.AddTransient(
|
||||
typeof(IPipelineBehavior<,>),
|
||||
typeof(SaveChangesPipelineBehaviour<,>)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue