/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Validation/test/Microsoft.Extensions.Validation.Tests/ValidationTestBase.cs
45 строк
1 KB
Youssef Fahmy
Move the abstract `Validatable*Info` from Microsoft.Extensions.Validation to be source-generated (#67956)
23 июл 2026, 11:45
Не верифицирован
23 июл 2026, 11:45
0ae3b02
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.Extensions.Validation.Tests; #nullable enable public abstract class ValidationTestBase { public static async Task ValidateAsync(IValidatableTypeInfo typeInfo, object? value, ValidateContext context, bool useAsync, CancellationToken cancellationToken) { if (useAsync) { await typeInfo.ValidateAsync(value, context, cancellationToken); } else { typeInfo.Validate(value, context); } } public static async Task ValidateAsync(IValidatablePropertyInfo propertyInfo, object containingObject, ValidateContext context, bool useAsync, CancellationToken cancellationToken) { if (useAsync) { await propertyInfo.ValidateAsync(containingObject, context, cancellationToken); } else { propertyInfo.Validate(containingObject, context); } } public static async Task ValidateAsync(IValidatableParameterInfo parameterInfo, object? value, ValidateContext context, bool useAsync, CancellationToken cancellationToken) { if (useAsync) { await parameterInfo.ValidateAsync(value, context, cancellationToken); } else { parameterInfo.Validate(value, context); } } }