Struct BinderContext
binder context supplied to custom request binders.
Implements
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public readonly struct BinderContext : IServiceResolverBaseConstructors
BinderContext(HttpContext, List<ValidationFailure>, JsonSerializerContext?, bool, IEnumerable<string>)
constructor of the binder context
Declaration
public BinderContext(HttpContext httpContext, List<ValidationFailure> validationFailures, JsonSerializerContext? jsonSerializerContext, bool dontAutoBindForms, IEnumerable<string> bindRequiredProps)Parameters
| Type | Name | Description | 
|---|---|---|
| HttpContext | httpContext | the http context of the current request | 
| List<ValidationFailure> | validationFailures | the validation failure collection of the endpoint | 
| JsonSerializerContext | jsonSerializerContext | json serializer context of the endpoint if applicable | 
| bool | dontAutoBindForms | whether to enable auto binding of form data | 
| IEnumerable<string> | bindRequiredProps | collection of required property names | 
Properties
DontAutoBindForms
set 'true' to disable auto binding of form data which enables uploading and reading of large files without buffering to memory/disk. you can access the multipart sections for reading via the FormFileSectionsAsync() method.
Declaration
public bool DontAutoBindForms { get; init; }Property Value
| Type | Description | 
|---|---|
| bool | 
HttpContext
the http context of the current request
Declaration
public HttpContext HttpContext { get; init; }Property Value
| Type | Description | 
|---|---|
| HttpContext | 
JsonSerializerContext
if the current endpoint is configured with a json serializer context, it will be provided to the custom request binder with this property.
Declaration
public JsonSerializerContext? JsonSerializerContext { get; init; }Property Value
| Type | Description | 
|---|---|
| JsonSerializerContext | 
SerializerOptions
the configured json serializer options of the app, which was specified at app startup.
Declaration
public JsonSerializerOptions SerializerOptions { get; }Property Value
| Type | Description | 
|---|---|
| JsonSerializerOptions | 
UnboundRequiredProperties
indicates which required properties were not bound due to missing input from the request.
Declaration
public IEnumerable<string> UnboundRequiredProperties { get; }Property Value
| Type | Description | 
|---|---|
| IEnumerable<string> | 
ValidationFailures
a list of validation failures for the endpoint. you can add your own validation failures for properties of the request dto using this property.
Declaration
public List<ValidationFailure> ValidationFailures { get; init; }Property Value
| Type | Description | 
|---|---|
| List<ValidationFailure> | 
Methods
CreateScope()
if you'd like to resolve scoped or transient services from the MS DI container, obtain a service scope from this method and dispose the scope when the work is complete.
<pre><code class="lang-csharp">using var scope = CreateScope();
var scopedService = scope.Resolve<MyService>();</code></pre>
Declaration
public IServiceScope CreateScope()Returns
| Type | Description | 
|---|---|
| IServiceScope | 
Resolve(Type)
resolve an instance for the given type from the dependency injection container. will throw if unresolvable.
Declaration
public object Resolve(Type typeOfService)Parameters
| Type | Name | Description | 
|---|---|---|
| Type | typeOfService | the type of the service to resolve | 
Returns
| Type | Description | 
|---|---|
| object | 
Exceptions
| Type | Condition | 
|---|---|
| InvalidOperationException | Thrown if requested service cannot be resolved | 
Resolve(Type, string)
resolve an instance for the given type from the dependency injection container. will throw if unresolvable.
Declaration
public object Resolve(Type typeOfService, string keyName)Parameters
| Type | Name | Description | 
|---|---|---|
| Type | typeOfService | the type of the service to resolve | 
| string | keyName | the key name for resolving keyed service | 
Returns
| Type | Description | 
|---|---|
| object | 
Exceptions
| Type | Condition | 
|---|---|
| InvalidOperationException | Thrown if requested service cannot be resolved | 
Resolve<TService>()
resolve an instance for the given type from the dependency injection container. will throw if unresolvable.
Declaration
public TService Resolve<TService>() where TService : classReturns
| Type | Description | 
|---|---|
| TService | 
Type Parameters
| Name | Description | 
|---|---|
| TService | the type of the service to resolve | 
Exceptions
| Type | Condition | 
|---|---|
| InvalidOperationException | Thrown if requested service cannot be resolved | 
Resolve<TService>(string)
resolve an instance for the given type from the dependency injection container. will throw if unresolvable.
Declaration
public TService Resolve<TService>(string keyName) where TService : classParameters
| Type | Name | Description | 
|---|---|---|
| string | keyName | the key name for resolving keyed service | 
Returns
| Type | Description | 
|---|---|
| TService | 
Type Parameters
| Name | Description | 
|---|---|
| TService | the type of the service to resolve | 
Exceptions
| Type | Condition | 
|---|---|
| InvalidOperationException | Thrown if requested service cannot be resolved | 
TryResolve(Type)
try to resolve an instance for the given type from the dependency injection container. will return null if unresolvable.
Declaration
public object? TryResolve(Type typeOfService)Parameters
| Type | Name | Description | 
|---|---|---|
| Type | typeOfService | the type of the service to resolve | 
Returns
| Type | Description | 
|---|---|
| object | 
TryResolve(Type, string)
try to resolve an instance for the given type from the dependency injection container. will return null if unresolvable.
Declaration
public object? TryResolve(Type typeOfService, string keyName)Parameters
| Type | Name | Description | 
|---|---|---|
| Type | typeOfService | the type of the service to resolve | 
| string | keyName | the key name for resolving keyed service | 
Returns
| Type | Description | 
|---|---|
| object | 
TryResolve<TService>()
try to resolve an instance for the given type from the dependency injection container. will return null if unresolvable.
Declaration
public TService? TryResolve<TService>() where TService : classReturns
| Type | Description | 
|---|---|
| TService | 
Type Parameters
| Name | Description | 
|---|---|
| TService | the type of the service to resolve | 
TryResolve<TService>(string)
try to resolve an instance for the given type from the dependency injection container. will return null if unresolvable.
Declaration
public TService? TryResolve<TService>(string keyName) where TService : classParameters
| Type | Name | Description | 
|---|---|---|
| string | keyName | the key name for resolving keyed service | 
Returns
| Type | Description | 
|---|---|
| TService | 
Type Parameters
| Name | Description | 
|---|---|
| TService | the type of the service to resolve |