Search Results for

    Show / Hide Table of Contents

    Class ServiceCollectionExtensions

    The service collection extensions.

    Inheritance
    System.Object
    ServiceCollectionExtensions
    Namespace: DisCatSharp.Hosting.DependencyInjection
    Assembly: DisCatSharp.Hosting.DependencyInjection.dll
    Syntax
    public static class ServiceCollectionExtensions

    Methods

    | Improve this Doc View Source

    AddDiscordHostedService<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 services for chaining purposes

    Type Parameters
    Name Description
    TService
    Remarks

    IDiscordHostedService is scoped to ServiceLifetime.Singleton.
    Maps to Implementation of TService

    | Improve this Doc View Source

    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 services for chaining purposes

    Type Parameters
    Name Description
    TInterface

    Interface which TService inherits from

    TService

    Your custom bot

    Remarks

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

    | Improve this Doc View Source

    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 services for chaining purposes

    Type Parameters
    Name Description
    TService
    Remarks

    IDiscordHostedShardService is scoped to ServiceLifetime.Singleton.
    Maps to Implementation of TService

    | Improve this Doc View Source

    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 services for chaining purposes

    Type Parameters
    Name Description
    TInterface

    Interface which TService inherits from

    TService

    Your custom bot

    Remarks

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

    • Improve this Doc
    • View Source
    In This Article
    Back to top © 2021-2022 Aiko IT Systems