Ejemplo n.º 1
0
 public void PriceChecking(object source, PriceCheckEventArgs args)
 {
     Console.WriteLine($"Validation service. Product type: {args.Product.Type}\tPrice: {args.Product.Price} ");
     //var validator = args.Product.Type == 1 ? typeof(Validator1) : typeof(Validator2);
     if (args.Product.Type == 1)
     {
         var validator = new Validator1();
         Console.WriteLine(validator.Validate(args.Product.Price) ? "Price is good" : "Price is bad");
     }
     else
     {
         var validator = new Validator2();
         Console.WriteLine(validator.Validate(args.Product.Price) ? "Price is good" : "Price is bad");
     }
 }