Table of Contents

Class IServiceCollectionExtensions

Namespace
SunamoDependencyInjection
Assembly
SunamoDependencyInjection.dll

Extension methods for IServiceCollection to add services ending with a specific suffix.

public static class IServiceCollectionExtensions
Inheritance
IServiceCollectionExtensions
Inherited Members

Methods

AddServicesEndingWith(IServiceCollection, Assembly, string, AddServicesEndingWithResult, bool, ServiceLifetime, ILogger, bool)

Adds services ending with a specific suffix from an assembly to the service collection.

public static void AddServicesEndingWith(this IServiceCollection services, Assembly assembly, string suffix, AddServicesEndingWithResult addServicesEndingWithResult, bool isOnlyExported, ServiceLifetime lifetime, ILogger logger, bool skipAlreadyRegistered = false)

Parameters

services IServiceCollection

The service collection to add services to.

assembly Assembly

The assembly to scan for services.

suffix string

The suffix to match (e.g., "Service").

addServicesEndingWithResult AddServicesEndingWithResult

The result object to populate with registered services.

isOnlyExported bool

Whether to only scan exported types.

lifetime ServiceLifetime

The service lifetime (Scoped, Singleton, or Transient).

logger ILogger

Logger for logging exceptions. REQUIRED.

skipAlreadyRegistered bool

When true, skips types (or their matching interfaces) that are already registered in the collection.

AddServicesEndingWithService(IServiceCollection, ILogger, string[], bool, ServiceLifetime, bool)

Adds all services ending with "Service" from Sunamo assemblies to the service collection.

public static AddServicesEndingWithResult AddServicesEndingWithService(this IServiceCollection services, ILogger logger, string[] additionalAssemblyPatterns, bool isAddingFromReferencedSunamoAssemblies = true, ServiceLifetime lifetime = ServiceLifetime.Scoped, bool skipAlreadyRegistered = false)

Parameters

services IServiceCollection

The service collection to add services to.

logger ILogger

Logger for logging exceptions during assembly loading. REQUIRED.

additionalAssemblyPatterns string[]

Additional assembly name patterns to scan (e.g., "SeznamkaCz").

isAddingFromReferencedSunamoAssemblies bool

Whether to add services from referenced Sunamo assemblies.

lifetime ServiceLifetime

The service lifetime (Scoped, Singleton, or Transient).

skipAlreadyRegistered bool

When true, skips types (or their matching interfaces) that are already registered in the collection.

Returns

AddServicesEndingWithResult

A result containing the registered classes and interfaces.