API reference
Method AddDiscordHostedService
- Namespace
- DisCatSharp.Hosting.DependencyInjection
- Assembly
- DisCatSharp.Hosting.DependencyInjection.dll
AddDiscordHostedService<TService>(IServiceCollection)
Adds your bot as a BackgroundService, registered in Dependency Injection as TService
public static IServiceCollection AddDiscordHostedService<TService>(this IServiceCollection services) where TService : class, IDiscordHostedService
Parameters
servicesIServiceCollection
Returns
- IServiceCollection
Reference to
servicesfor chaining purposes
Type Parameters
TService
Remarks
IDiscordHostedService is scoped to ServiceLifetime.Singleton.
Maps to Implementation of TService
AddDiscordHostedService<TInterface, TService>(IServiceCollection)
Add TService as a background service which derives from
TInterface and IDiscordHostedService
public static IServiceCollection AddDiscordHostedService<TInterface, TService>(this IServiceCollection services) where TInterface : class, IDiscordHostedService where TService : class, TInterface, IDiscordHostedService
Parameters
servicesIServiceCollection
Returns
- IServiceCollection
Reference to
servicesfor chaining purposes
Type Parameters
TInterfaceInterface which
TServiceinherits fromTServiceYour custom bot
Remarks
To retrieve your bot via Dependency Injection you can reference it via TInterface