Table of Contents

Class ServiceExtensions

Namespace
BSGameLib.Game
Assembly
BSGameLib.Game.dll

Extension methods that register the framework's services with dependency injection.

public static class ServiceExtensions
Inheritance
ServiceExtensions
Inherited Members

Methods

FindAndRegisterImplementations(IServiceCollection, Type, ServiceLifetime)

Registers every class assignable to targetType found in the loaded non-system assemblies, as its implemented interfaces. Registrations that already exist are kept.

public static IServiceCollection FindAndRegisterImplementations(this IServiceCollection services, Type targetType, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

services IServiceCollection
targetType Type
lifetime ServiceLifetime

Returns

IServiceCollection

FindAndRegisterImplementations<TAbstract>(IServiceCollection, ServiceLifetime)

Registers every class that implements TAbstract, with lifetime (transient unless given). See the non-generic overload.

public static IServiceCollection FindAndRegisterImplementations<TAbstract>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient) where TAbstract : class

Parameters

services IServiceCollection
lifetime ServiceLifetime

Returns

IServiceCollection

Type Parameters

TAbstract

RegisterImplementationsOf<TAbstract>(IServiceCollection, ServiceLifetime)

Registers every concrete class that implements TAbstract, found in the loaded non-system assemblies. Each is also registered under TAbstract and its interfaces.

public static IServiceCollection RegisterImplementationsOf<TAbstract>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient) where TAbstract : class

Parameters

services IServiceCollection
lifetime ServiceLifetime

Returns

IServiceCollection

Type Parameters

TAbstract