API reference
Method AddDiscordHostedShardService
- Namespace
- DisCatSharp.Hosting.DependencyInjection
- Assembly
- DisCatSharp.Hosting.DependencyInjection.dll
AddDiscordHostedShardService<TService>(IServiceCollection)
Adds your bot as a BackgroundService, registered in Dependency Injection as TService
public static IServiceCollection AddDiscordHostedShardService<TService>(this IServiceCollection services) where TService : class, IDiscordHostedShardService
Parameters
servicesIServiceCollection
Returns
- IServiceCollection
Reference to
servicesfor chaining purposes
Type Parameters
TService
Remarks
IDiscordHostedShardService is scoped to ServiceLifetime.Singleton.
Maps to Implementation of TService
AddDiscordHostedShardService<TInterface, TService>(IServiceCollection)
Add TService as a background service which derives from
TInterface and IDiscordHostedShardService
public static IServiceCollection AddDiscordHostedShardService<TInterface, TService>(this IServiceCollection services) where TInterface : class, IDiscordHostedShardService where TService : class, TInterface, IDiscordHostedShardService
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