Пример #1
0
        /// <summary>
        /// Runs the asynchronous validation process.
        /// </summary>
        /// <param name="newValidationValue">New validation value to validate.</param>
        /// <returns>Returns the validation result.</returns>
        public async Task <ValidationStatus> ValidateAsync(object newValidationValue)
        {
            if (!inputComponent.Disabled)
            {
                cancellationTokenSource?.Cancel();

                // Create a CTS for this request.
                cancellationTokenSource = new();

                var cancellationToken = cancellationTokenSource.Token;

                try
                {
                    var validationHandlerType = DetermineHandlerType();

                    cancellationToken.ThrowIfCancellationRequested();

                    if (validationHandlerType != null)
                    {
                        var validationHandler = ValidationHandlerFactory.Create(validationHandlerType);

                        cancellationToken.ThrowIfCancellationRequested();

                        await validationHandler.ValidateAsync(this, newValidationValue, cancellationToken);
                    }
                }
                catch (OperationCanceledException)
                {
                }
            }

            return(await Task.FromResult(Status));
        }
Пример #2
0
        /// <summary>
        /// Runs the validation process.
        /// </summary>
        /// <param name="newValidationValue">New validation value to validate.</param>
        /// <returns>Returns the validation result.</returns>
        public ValidationStatus Validate(object newValidationValue)
        {
            if (!inputComponent.Disabled)
            {
                var validationHandlerType = DetermineHandlerType();

                if (validationHandlerType != null)
                {
                    var validationHandler = ValidationHandlerFactory.Create(validationHandlerType);

                    validationHandler.Validate(this, newValidationValue);
                }
            }

            return(Status);
        }