Table of Contents
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

services IServiceCollection

Returns

IServiceCollection

Reference to services for 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

services IServiceCollection

Returns

IServiceCollection

Reference to services for chaining purposes

Type Parameters

TInterface

Interface which TService inherits from

TService

Your custom bot

Remarks

To retrieve your bot via Dependency Injection you can reference it via TInterface