Beispiel #1
0
        public override void ApplySausage(SausageDecorator decorator, Sausage sausage)
        {
            if (decorator is AddSausage)
            {
                var validator           = new SausageValidator();
                var vegetablesValidator = new VegetablesValidator();

                var command = new SetNextCommand(vegetablesValidator);
                command.Execute(validator);

                if (validator.IsValid(pizza.SausageTypeList.Sausages) != null)
                {
                    if (validator.IsValid(pizza.SausageTypeList.Sausages).Value)
                    {
                        pizza.SausageTypeList.Sausages.Add(sausage);
                        SausageDecorator sausageDecorator = new AddSausage(sausage);
                        pizza.SausageTypeList.TotalCost = sausageDecorator.GetCost();
                    }
                    else
                    {
                        Console.WriteLine("Value is not valid");
                    }
                }
            }
        }
Beispiel #2
0
 public AddSausage(Sausage sausage) : base(sausage)
 {
 }
Beispiel #3
0
 public SausageDecorator(Sausage sausage)
 {
     _sausage = sausage;
 }
Beispiel #4
0
 public abstract void ApplySausage(SausageDecorator decorator, Sausage sausage);