Table of Contents

Class UserContextProvider

Namespace
BytLabs.Application.UserContext
Assembly
BytLabs.Application.dll

Implements a composite pattern for user identification by aggregating multiple resolvers. Provides fallback mechanisms when primary identification methods fail.

public sealed class UserContextProvider : IUserContextProvider
Inheritance
UserContextProvider
Implements
Inherited Members

Constructors

UserContextProvider(IEnumerable<IUserContextResolver>, ILogger<UserContextProvider>)

Initializes a new instance of the UserContextProvider.

public UserContextProvider(IEnumerable<IUserContextResolver> resolvers, ILogger<UserContextProvider> logger)

Parameters

resolvers IEnumerable<IUserContextResolver>

Collection of resolvers for user identification

logger ILogger<UserContextProvider>

Exceptions

ArgumentNullException

Thrown when resolvers is null

Methods

GetUserId()

Attempts to identify the current user using configured resolvers.

public string GetUserId()

Returns

string

The first valid user ID found, or KnownUserId.Unknown if no resolver succeeds