ValidationAttributeFormatterRegistry Klas
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Register van IValidationAttributeFormatter factory's gesleuteld op ValidationAttribute type. Wordt gebruikt door de validatielokalisatiepijplijn voor het opmaken van gelokaliseerde foutberichtsjablonen met kenmerkspecifieke argumenten.
public ref class ValidationAttributeFormatterRegistry sealed
public sealed class ValidationAttributeFormatterRegistry
type ValidationAttributeFormatterRegistry = class
Public NotInheritable Class ValidationAttributeFormatterRegistry
- Overname
-
ValidationAttributeFormatterRegistry
Opmerkingen
Oplossingsvolgorde:
- Als het kenmerk zichzelf implementeert IValidationAttributeFormatter (zelfopmaak), wordt het rechtstreeks geretourneerd.
- Als een fabriek is geregistreerd voor het type van het kenmerk via AddFormatter<TAttribute>(Func<TAttribute,IValidationAttributeFormatter>), wordt deze gebruikt om een formatter te maken.
- Anders wordt
nullgeretourneerd, wat aangeeft dat er geen kenmerkspecifieke formatter beschikbaar is.
Ingebouwde indelingen voor standaardvalidatiekenmerken (zoals RangeAttribute, MinLengthAttributeStringLengthAttribute, enzovoort) worden automatisch geregistreerd. Latere registraties voor hetzelfde kenmerktype vervangen eerdere registraties.
builder.Services.AddValidationLocalization(options =>
options.AttributeFormatters.AddFormatter<CreditCardAttribute>(
attribute => new CreditCardAttributeFormatter(attribute)));
Constructors
| Name | Description |
|---|---|
| ValidationAttributeFormatterRegistry() |
Hiermee maakt u een nieuw exemplaar van ValidationAttributeFormatterRegistry met ingebouwde formatters voor standaardvalidatiekenmerken. |
Methoden
| Name | Description |
|---|---|
| AddFormatter<TAttribute>(Func<TAttribute,IValidationAttributeFormatter>) |
Registreert een formatter factory voor het opgegeven type validatiekenmerk. Latere registraties voor hetzelfde type vervangen eerdere registraties. |
| GetFormatter(ValidationAttribute) |
Retourneert een IValidationAttributeFormatter voor de opgegeven |