ValidationAttributeFormatterRegistry.AddFormatter<TAttribute> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers a formatter factory for the specified validation attribute type. Later registrations for the same type replace earlier ones.
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))
Type Parameters
- TAttribute
The validation attribute type to register a formatter for.
Parameters
- factory
- Func<TAttribute,IValidationAttributeFormatter>
A factory delegate that creates an IValidationAttributeFormatter from the attribute instance.
Remarks
Configuration is intended to happen during application startup. Mutating the registry after the validation pipeline has begun processing requests is not thread-safe.