Table of Contents

Class ScopedServiceProviderAccessor

Namespace
Arc4u.OAuth2.AspNetCore
Assembly
Arc4u.OAuth2.AspNetCore.dll

Gives access to the IServiceProvider of the current scope: the one set explicitly for the current async flow, otherwise the one of the current HTTP request.

[Export(typeof(IScopedServiceProviderAccessor))]
[Shared]
public class ScopedServiceProviderAccessor : IScopedServiceProviderAccessor
Inheritance
ScopedServiceProviderAccessor
Implements
Inherited Members

Constructors

ScopedServiceProviderAccessor(IHttpContextAccessor)

Initializes a new instance of the ScopedServiceProviderAccessor class. The http context accessor is never null on a service, but its HttpContext is null when the code does not run in a request, for example in a background job.

public ScopedServiceProviderAccessor(IHttpContextAccessor httpContextAccessor)

Parameters

httpContextAccessor IHttpContextAccessor

The accessor of the current HTTP context.

Properties

ServiceProvider

Gets or sets the IServiceProvider of the current scope (for example the current HTTP request or Blazor circuit).

public IServiceProvider ServiceProvider { get; set; }

Property Value

IServiceProvider

Exceptions

NullReferenceException

Getter: no service provider was set for the current async flow and there is no current HTTP request.

ArgumentNullException

Setter: the value is null.

ArgumentException

Setter: the value is not an IServiceScope.

Methods

InvalidateServiceProvider()

Clears the service provider set for the current async flow, for example when its scope is disposed.

public void InvalidateServiceProvider()