Class ResourceCollectionNameServiceCollectionExtensions
Extension methods for registering ResourceCollectionNameOverride entries and the consuming ResourceCollectionNameRegistry.
public static class ResourceCollectionNameServiceCollectionExtensions
- Inheritance
-
ResourceCollectionNameServiceCollectionExtensions
- Inherited Members
Methods
AddResourceCollectionName(IServiceCollection, string, string)
Registers a single resource-type-to-collection-name override using an explicit resource-type string. Use when For(string, object?) is emitted with a custom name that does not match any CLR type. Safe under trimming/AOT — does not perform assembly scanning.
public static IServiceCollection AddResourceCollectionName(this IServiceCollection services, string resourceType, string collectionName)
Parameters
servicesIServiceCollectionThe service collection.
resourceTypestringThe Type value (case-insensitive).
collectionNamestringThe collection segment to substitute (e.g.
"people").
Returns
- IServiceCollection
The service collection for chaining.
AddResourceCollectionName<TResource>(IServiceCollection, string)
Registers a single resource-type-to-collection-name override. The lookup key is the resource
name For<TResource>(object?) emits for TResource,
which is the simple CLR name with any generic backtick suffix stripped and any
Maybe<T> wrapper peeled — so registering Maybe<Order> and
Order produce the same entry. Safe under trimming/AOT — does not perform assembly scanning.
public static IServiceCollection AddResourceCollectionName<TResource>(this IServiceCollection services, string collectionName)
Parameters
servicesIServiceCollectionThe service collection.
collectionNamestringThe collection segment to substitute (e.g.
"people").
Returns
- IServiceCollection
The service collection for chaining.
Type Parameters
TResourceThe CLR resource type whose Type name should map to
collectionName.
AddResourceCollectionNames(IServiceCollection, Assembly)
Scans the supplied assembly for types annotated with ResourceCollectionNameAttribute and registers one ResourceCollectionNameOverride per match. The resource-type lookup key is FormatTypeName(Type) of the annotated type, matching the name emitted by For<TResource>(object?).
[RequiresUnreferencedCode("Assembly scanning may load types that have been trimmed. For AOT/trimming use AddResourceCollectionName<T>(name) for each override.")]
public static IServiceCollection AddResourceCollectionNames(this IServiceCollection services, Assembly assembly)
Parameters
servicesIServiceCollectionThe service collection.
assemblyAssemblyThe assembly to scan.
Returns
- IServiceCollection
The service collection for chaining.
Remarks
Conflicting overrides for the same resource type (different collection names) are detected when the registry is activated, not here, so a misconfiguration surfaces on first resolve rather than tearing down composition root.
AddResourceCollectionNames(IServiceCollection, params Assembly[])
Scans the supplied assemblies for types annotated with ResourceCollectionNameAttribute. Convenience overload for hosts that register overrides from more than one assembly in a single call. Each assembly is scanned in order; identical overrides across assemblies coalesce silently when the registry is activated, conflicting overrides throw.
[RequiresUnreferencedCode("Assembly scanning may load types that have been trimmed. For AOT/trimming use AddResourceCollectionName<T>(name) for each override.")]
public static IServiceCollection AddResourceCollectionNames(this IServiceCollection services, params Assembly[] assemblies)
Parameters
servicesIServiceCollectionThe service collection.
assembliesAssembly[]The assemblies to scan.
Returns
- IServiceCollection
The service collection for chaining.