Wolfringo Wolfringo
Wolfringo Wolfringo
Wolfringo (c) 2020 TehGM
DocFX, DiscordFX theme.
Search Results for

    Class DisposableServicesHandler

    An utility class for handling services that should be disposed (when created by provider/builder, and not by library user).

    Inheritance
    System.Object
    DisposableServicesHandler
    Implements
    System.IDisposable
    Namespace: TehGM.Wolfringo.Utilities.Internal
    Assembly: Wolfringo.Core.dll
    Syntax
    public class DisposableServicesHandler : IDisposable
    Remarks

    Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.

    Only singleton services should be marked for disposal.

    Methods

    | Improve this Doc View Source

    Dispose()

    Disposes all tracked disposable services, and stops tracking them.

    Declaration
    public void Dispose()
    Remarks

    Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.

    Only singleton services should be marked for disposal.

    | Improve this Doc View Source

    GetRequiredService<T>(IServiceProvider)

    Gets required service from provider. If service is marked for disposal, it'll automatically be tracked and disposed when Dispose() is used.

    Declaration
    public T GetRequiredService<T>(IServiceProvider services)
    Parameters
    Type Name Description
    System.IServiceProvider services

    Service provider to resolve the service from.

    Returns
    Type Description
    T

    The resolved service.

    Type Parameters
    Name Description
    T

    Type of the service to get.

    Remarks

    Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.

    Only singleton services should be marked for disposal.

    | Improve this Doc View Source

    GetService<T>(IServiceProvider)

    Gets service from provider. If service is marked for disposal, it'll automatically be tracked and disposed when Dispose() is used.

    Declaration
    public T GetService<T>(IServiceProvider services)
    Parameters
    Type Name Description
    System.IServiceProvider services

    Service provider to resolve the service from.

    Returns
    Type Description
    T

    The resolved service; null if not found.

    Type Parameters
    Name Description
    T

    Type of the service to get.

    Remarks

    Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.

    Only singleton services should be marked for disposal.

    | Improve this Doc View Source

    MarkForDisposal(Type)

    Marks service type to be disposed.

    Declaration
    public void MarkForDisposal(Type type)
    Parameters
    Type Name Description
    System.Type type

    Type of the service.

    Remarks

    Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.

    Only singleton services should be marked for disposal.

    | Improve this Doc View Source

    MarkForDisposal<T>()

    Marks service type to be disposed.

    Declaration
    public void MarkForDisposal<T>()
    Type Parameters
    Name Description
    T

    Type of the service.

    Remarks

    Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.

    Only singleton services should be marked for disposal.

    | Improve this Doc View Source

    UnmarkForDisposal(Type)

    Removes disposal mark from the service type.

    Declaration
    public void UnmarkForDisposal(Type type)
    Parameters
    Type Name Description
    System.Type type

    Type of the service.

    Remarks

    Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.

    Only singleton services should be marked for disposal.

    | Improve this Doc View Source

    UnmarkForDisposal<T>()

    Removes disposal mark from the service type.

    Declaration
    public void UnmarkForDisposal<T>()
    Type Parameters
    Name Description
    T

    Type of the service.

    Remarks

    Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.

    Only singleton services should be marked for disposal.

    Implements

    System.IDisposable