Class ServiceCollectionExtensions
The service collection extensions.
Inheritance
Namespace: DisCatSharp.Hosting.DependencyInjection
Assembly: DisCatSharp.Hosting.DependencyInjection.dll
Syntax
public static class ServiceCollectionExtensions
Methods
| Improve this Doc View SourceAddDiscordHostedService<TService>(IServiceCollection)
Adds your bot as a BackgroundService, registered in Dependency Injection as TService
Declaration
public static IServiceCollection AddDiscordHostedService<TService>(this IServiceCollection services)
where TService : class, IDiscordHostedService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | Reference to |
Type Parameters
Name | Description |
---|---|
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
Declaration
public static IServiceCollection AddDiscordHostedService<TInterface, TService>(this IServiceCollection services)
where TInterface : class, IDiscordHostedService where TService : class, TInterface, IDiscordHostedService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | Reference to |
Type Parameters
Name | Description |
---|---|
TInterface | Interface which |
TService | Your custom bot |
Remarks
To retrieve your bot via Dependency Injection you can reference it via TInterface
AddDiscordHostedShardService<TService>(IServiceCollection)
Adds your bot as a BackgroundService, registered in Dependency Injection as TService
Declaration
public static IServiceCollection AddDiscordHostedShardService<TService>(this IServiceCollection services)
where TService : class, IDiscordHostedShardService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | Reference to |
Type Parameters
Name | Description |
---|---|
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
Declaration
public static IServiceCollection AddDiscordHostedShardService<TInterface, TService>(this IServiceCollection services)
where TInterface : class, IDiscordHostedShardService where TService : class, TInterface, IDiscordHostedShardService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | Reference to |
Type Parameters
Name | Description |
---|---|
TInterface | Interface which |
TService | Your custom bot |
Remarks
To retrieve your bot via Dependency Injection you can reference it via TInterface