FromServicesAttribute Clase

Definición

Especifica que un parámetro o propiedad debe enlazarse mediante los servicios de solicitud.

public ref class FromServicesAttribute : Attribute, Microsoft::AspNetCore::Mvc::ModelBinding::IBindingSourceMetadata
[System.AttributeUsage(System.AttributeTargets.Parameter, AllowMultiple=false, Inherited=true)]
public class FromServicesAttribute : Attribute, Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata
[System.AttributeUsage(System.AttributeTargets.Parameter, AllowMultiple=false, Inherited=true)]
public class FromServicesAttribute : Attribute, Microsoft.AspNetCore.Http.Metadata.IFromServiceMetadata, Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata
[System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)]
public class FromServicesAttribute : Attribute, Microsoft.AspNetCore.Http.Metadata.IFromServiceMetadata, Microsoft.AspNetCore.Mvc.ModelBinding.IBindingSourceMetadata
[<System.AttributeUsage(System.AttributeTargets.Parameter, AllowMultiple=false, Inherited=true)>]
type FromServicesAttribute = class
    inherit Attribute
    interface IBindingSourceMetadata
[<System.AttributeUsage(System.AttributeTargets.Parameter, AllowMultiple=false, Inherited=true)>]
type FromServicesAttribute = class
    inherit Attribute
    interface IBindingSourceMetadata
    interface IFromServiceMetadata
[<System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false, Inherited=true)>]
type FromServicesAttribute = class
    inherit Attribute
    interface IBindingSourceMetadata
    interface IFromServiceMetadata
Public Class FromServicesAttribute
Inherits Attribute
Implements IBindingSourceMetadata
Public Class FromServicesAttribute
Inherits Attribute
Implements IBindingSourceMetadata, IFromServiceMetadata
Herencia
FromServicesAttribute
Atributos
Implementaciones

Ejemplos

En este ejemplo, se registra como servicio una implementación de IProductModelRequestService. A continuación, en la acción GetProduct, el parámetro se enlaza a una instancia de IProductModelRequestService que se resuelve desde los servicios de solicitud.

[HttpGet]
public ProductModel GetProduct([FromServices] IProductModelRequestService productModelRequest)
{
    return productModelRequest.Value;
}

Constructores

FromServicesAttribute()

Especifica que un parámetro o propiedad debe enlazarse mediante los servicios de solicitud.

Propiedades

BindingSource

Obtiene la estructura BindingSource.

Se aplica a