BusinessLogic.Models.Games.Validation.PlayerRankValidationAttribute.IsValid C# (CSharp) Метод

IsValid() защищенный Метод

protected IsValid ( object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext ) : System.ComponentModel.DataAnnotations.ValidationResult
value object
validationContext System.ComponentModel.DataAnnotations.ValidationContext
Результат System.ComponentModel.DataAnnotations.ValidationResult
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var playerRanks = (value as IEnumerable<IPlayerRank>).ToList();

            try
            {
                PlayerRankValidator.ValidatePlayerRanks(playerRanks);

                return ValidationResult.Success;
            }catch(ArgumentException argumentException)
            {
                return new ValidationResult(argumentException.Message);
            }
        }
    }
PlayerRankValidationAttribute