using Knot.Contracts.Messaging.Application.Abstractions; using Knot.Contracts.Messaging.Domain; using Knot.Modules.Conversations.Application.Abstractions; using Knot.Modules.Conversations.Domain; using Knot.Modules.Conversations.Infrastructure.Persistence; using Knot.Modules.Conversations.Infrastructure.Persistence.Mongo; using Knot.Shared.Kernel; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace Knot.Modules.Conversations; public static class DependencyInjection { public static IServiceCollection AddConversationsModule( this IServiceCollection services, IConfiguration configuration) { string connectionString = configuration.GetConnectionString("DefaultConnection")!; services.AddDbContext(options => options.UseNpgsql(connectionString)); // MongoDB Setup for Messages ConversationsMongoDbMapConfigurator.Configure(); var mongoConnectionString = configuration.GetConnectionString("MongoConnection") ?? "mongodb://localhost:27017"; // Registration services.AddScoped(sp => sp.GetRequiredService()); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); // Messaging Repository - registered in Messaging module // services.AddScoped(); // MediatR services.AddMediatR(config => config.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly)); services.AddScoped(); services.AddScoped(); services.AddScoped(); return services; } }