ValidationAttributeFormatterRegistry.AddFormatter<TAttribute> Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Inscrit une fabrique de formateur pour le type d’attribut de validation spécifié. Les inscriptions ultérieures pour le même type remplacent les inscriptions antérieures.
public:
generic <typename TAttribute>
where TAttribute : System::ComponentModel::DataAnnotations::ValidationAttribute void AddFormatter(Func<TAttribute, Microsoft::Extensions::Validation::Localization::IValidationAttributeFormatter ^> ^ factory);
public void AddFormatter<TAttribute>(Func<TAttribute,Microsoft.Extensions.Validation.Localization.IValidationAttributeFormatter> factory) where TAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute;
member this.AddFormatter : Func<'Attribute, Microsoft.Extensions.Validation.Localization.IValidationAttributeFormatter (requires 'Attribute :> System.ComponentModel.DataAnnotations.ValidationAttribute)> -> unit (requires 'Attribute :> System.ComponentModel.DataAnnotations.ValidationAttribute)
Public Sub AddFormatter(Of TAttribute As ValidationAttribute) (factory As Func(Of TAttribute, IValidationAttributeFormatter))
Paramètres de type
- TAttribute
Type d’attribut de validation pour lequel inscrire un formateur.
Paramètres
- factory
- Func<TAttribute,IValidationAttributeFormatter>
Délégué d’usine qui crée une IValidationAttributeFormatter instance d’attribut.
Remarques
La configuration est destinée à se produire au démarrage de l’application. Le mutation du Registre une fois que le pipeline de validation a commencé à traiter les demandes n’est pas thread-safe.