public void Visit(StringValidation validation, ValidatorParam value) { try { validation.Validate(value.StringValue); } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { var validations = new List<IValidation> { new IntValidation(i => i < 10), new StringValidation(s => s.Length < 10) }; var validatorParam = new ValidatorParam(10, "0123456789"); var validatorVisitor = new ValidatorVisitor(true); foreach (var validation in validations) { validation.Accept(validatorVisitor, validatorParam); } Console.ReadLine(); }