| | | 1 | | using Microsoft.Extensions.DependencyInjection; |
| | | 2 | | |
| | | 3 | | namespace NLightning.Infrastructure; |
| | | 4 | | |
| | | 5 | | using Crypto.Hashes; |
| | | 6 | | using Domain.Crypto.Hashes; |
| | | 7 | | using Domain.Node.Interfaces; |
| | | 8 | | using Domain.Protocol.Interfaces; |
| | | 9 | | using Node.Factories; |
| | | 10 | | using Protocol.Factories; |
| | | 11 | | using Protocol.Services; |
| | | 12 | | using Transport.Factories; |
| | | 13 | | using Transport.Interfaces; |
| | | 14 | | using Transport.Services; |
| | | 15 | | |
| | | 16 | | public static class DependencyInjection |
| | | 17 | | { |
| | | 18 | | public static IServiceCollection AddInfrastructureServices(this IServiceCollection services) |
| | | 19 | | { |
| | | 20 | | // Singleton services (one instance throughout the application) |
| | 0 | 21 | | services.AddSingleton<IChannelIdFactory, ChannelIdFactory>(); |
| | 0 | 22 | | services.AddSingleton<IMessageServiceFactory, MessageServiceFactory>(); |
| | 0 | 23 | | services.AddSingleton<IPeerServiceFactory, PeerServiceFactory>(); |
| | 0 | 24 | | services.AddSingleton<ITcpService, TcpService>(); |
| | 0 | 25 | | services.AddSingleton<ISha256, Sha256>(); |
| | 0 | 26 | | services.AddSingleton<ITransportServiceFactory, TransportServiceFactory>(); |
| | | 27 | | |
| | | 28 | | // Transient services (new instance each time requested) |
| | 0 | 29 | | services.AddTransient<IPingPongService, PingPongService>(); |
| | | 30 | | |
| | 0 | 31 | | return services; |
| | | 32 | | } |
| | | 33 | | } |