Files
Flypaper/src/Flypaper.Storage/FlypaperStorageExtensions.cs
T

18 lines
652 B
C#

using Flypaper.Core;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Flypaper.Storage;
public static class FlypaperStorageExtensions
{
public static IServiceCollection AddFlypaperStorage(this IServiceCollection services, string connectionString)
{
services.AddDbContextFactory<FlypaperDbContext>(options => options.UseSqlite(connectionString));
services.AddSingleton<ChannelTrapEventSink>();
services.AddSingleton<ITrapEventSink>(sp => sp.GetRequiredService<ChannelTrapEventSink>());
services.AddHostedService<TrapEventWriter>();
return services;
}
}