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
servicesIServiceCollectionThe service collection to add services to.
assemblyAssemblyThe assembly to scan for services.
suffixstringThe suffix to match (e.g., "Service").
addServicesEndingWithResultAddServicesEndingWithResultThe result object to populate with registered services.
isOnlyExportedboolWhether to only scan exported types.
lifetimeServiceLifetimeThe service lifetime (Scoped, Singleton, or Transient).
loggerILoggerLogger for logging exceptions. REQUIRED.
skipAlreadyRegisteredboolWhen 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
servicesIServiceCollectionThe service collection to add services to.
loggerILoggerLogger for logging exceptions during assembly loading. REQUIRED.
additionalAssemblyPatternsstring[]Additional assembly name patterns to scan (e.g., "SeznamkaCz").
isAddingFromReferencedSunamoAssembliesboolWhether to add services from referenced Sunamo assemblies.
lifetimeServiceLifetimeThe service lifetime (Scoped, Singleton, or Transient).
skipAlreadyRegisteredboolWhen true, skips types (or their matching interfaces) that are already registered in the collection.
Returns
- AddServicesEndingWithResult
A result containing the registered classes and interfaces.