diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-09-13 21:49:05 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-09-13 21:49:05 -0500 |
| commit | 7837f702589935886935754ee6136329d47d025d (patch) | |
| tree | 95ba356d36d5f8e5e1733eb4ba126f1eec03c01a /src | |
| parent | 1a887740f6241b73e1962381dc534b74b6dd9f2b (diff) | |
| download | slskd-7837f702589935886935754ee6136329d47d025d.tar.gz | |
add SoulseekClient to DI
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Startup.cs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs index c8c96584..d147efef 100644 --- a/src/slskd/Startup.cs +++ b/src/slskd/Startup.cs @@ -37,12 +37,12 @@ namespace slskd using slskd.Cryptography; using slskd.Integrations.FTP; using slskd.Integrations.Pushbullet; - using slskd.Management; using slskd.Messaging; using slskd.Peer; using slskd.Search; using slskd.Transfer; using slskd.Validation; + using Soulseek; /// <summary> /// ASP.NET Startup. @@ -199,6 +199,16 @@ namespace slskd services.AddHttpClient(); + // add a partially configured instance of SoulseekClient. the Application instance will + // complete configuration at startup. + services.AddSingleton<ISoulseekClient, SoulseekClient>(_ => + new SoulseekClient(options: new SoulseekClientOptions(minimumDiagnosticLevel: OptionsAtStartup.Soulseek.DiagnosticLevel))); + + // add Application to DI as well as a hosted service so that other services can + // access instance methods + services.AddSingleton<IApplication, Application>(); + services.AddHostedService(p => p.GetRequiredService<IApplication>()); + services.AddSingleton<ITransferTracker, TransferTracker>(); services.AddSingleton<IBrowseTracker, BrowseTracker>(); services.AddSingleton<IConversationTracker, ConversationTracker>(); @@ -208,16 +218,12 @@ namespace slskd services.AddSingleton<ISearchService, SearchService>(); services.AddSingleton<IPeerService, PeerService>(); + services.AddSingleton<IRoomService, RoomService>(); services.AddSingleton<IFTPClientFactory, FTPClientFactory>(); services.AddSingleton<IFTPService, FTPService>(); services.AddSingleton<IPushbulletService, PushbulletService>(); - - services.AddTransient<ISoulseekClientFactory, SoulseekClientFactory>(); - - services.AddSingleton<IApplication, Application>(); - services.AddHostedService(p => p.GetRequiredService<IApplication>()); } /// <summary> @@ -265,7 +271,7 @@ namespace slskd FileServerOptions fileServerOptions = default; - if (!Directory.Exists(ContentPath)) + if (!System.IO.Directory.Exists(ContentPath)) { logger.Warning($"Static content disabled; cannot find content path '{ContentPath}'"); } @@ -330,7 +336,7 @@ namespace slskd // finally, hit the fileserver again. if the path was modified to return the index above, the index document will be // returned. otherwise it will throw a final 404 back to the client. - if (Directory.Exists(ContentPath)) + if (System.IO.Directory.Exists(ContentPath)) { app.UseFileServer(fileServerOptions); } |
