Пример #1
0
 public void Visit(StringValidation validation, ValidatorParam value)
 {
     try
       {
     validation.Validate(value.StringValue);
       }
       catch (Exception e)
       {
     Console.WriteLine(e.Message);
       }
 }
Пример #2
0
        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();
        }