OptionsBuilderDataAnnotationsExtensions.ValidateDataAnnotations<TOptions> Methode
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.
Registreert dit optieexemplaren voor validatie van de bijbehorende DataAnnotations.
public:
generic <typename TOptions>
where TOptions : class[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::Options::OptionsBuilder<TOptions> ^ ValidateDataAnnotations(Microsoft::Extensions::Options::OptionsBuilder<TOptions> ^ optionsBuilder);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Uses DataAnnotationValidateOptions which is unsafe given that the options type passed in when calling Validate cannot be statically analyzed so its members may be trimmed.")]
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> ValidateDataAnnotations<TOptions>(this Microsoft.Extensions.Options.OptionsBuilder<TOptions> optionsBuilder) where TOptions : class;
public static Microsoft.Extensions.Options.OptionsBuilder<TOptions> ValidateDataAnnotations<TOptions>(this Microsoft.Extensions.Options.OptionsBuilder<TOptions> optionsBuilder) where TOptions : class;
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Uses DataAnnotationValidateOptions which is unsafe given that the options type passed in when calling Validate cannot be statically analyzed so its members may be trimmed.")>]
static member ValidateDataAnnotations : Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> -> Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> (requires 'Options : null)
static member ValidateDataAnnotations : Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> -> Microsoft.Extensions.Options.OptionsBuilder<'Options (requires 'Options : null)> (requires 'Options : null)
<Extension()>
Public Function ValidateDataAnnotations(Of TOptions As Class) (optionsBuilder As OptionsBuilder(Of TOptions)) As OptionsBuilder(Of TOptions)
Type parameters
- TOptions
Het type opties dat moet worden geconfigureerd.
Parameters
- optionsBuilder
- OptionsBuilder<TOptions>
De opbouwfunctie voor opties waaraan u de services wilt toevoegen.
Retouren
De OptionsBuilder<TOptions> zodat extra aanroepen kunnen worden gekoppeld.
- Kenmerken
Opmerkingen
Synchrone validatie wordt uitgevoerd wanneer het optiesexemplaren worden gemaakt of geopend. Wanneer u zich richt op .NET 11 of hoger, wordt asynchrone validatie (inclusief AsyncValidationAttribute-afgeleide kenmerken) eenmaal uitgevoerd bij het opstarten en alleen wanneer ValidateOnStart() deze ook wordt aangeroepen. Als ValidateOnStart() dit niet wordt aangeroepen, worden kenmerken waaruit wordt afgeleid AsyncValidationAttribute nooit asynchroon geƫvalueerd: runtimeopties openen triggers alleen synchrone validatie, die in plaats daarvan de synchrone terugval van het kenmerk aanroept. Wanneer u AsyncValidationAttribute-afgeleide kenmerken gebruikt, moet u ervoor zorgen dat de synchrone IsValid terugval niet wordt gegenereerd: synchrone validatie wordt nog steeds uitgevoerd op alle opties, dus een terugvaloppervlak als uitzondering voor elke toegang (bijvoorbeeld bij het IOptions{TOptions}.Valueoplossen), zelfs als de opstartvalidatie is geslaagd.