static void Main(string[] args)
        {
            var container = new Container(cfg =>
            {
                cfg.Scan(scanner =>
                {
                    scanner.AddAllTypesOf<IDiscounter>();

                    scanner.AssemblyContainingType<Program>();
                    scanner.WithDefaultConventions();
                });

                cfg.For<IInvoiceApprover>().DecorateAllWith<LoggingInvoiceApprover>();
                cfg.ForSingletonOf<EmailSender>().Use<EmailSender>();
            });

            var approver = container.GetInstance<IInvoiceApprover>();
            var invoice = new Invoice
            {
                Total = 2000m,
                Customer = "Joe",
                State = "KS"
            };

            approver.Approve(invoice);
        }
 public decimal Apply(Invoice invoice)
 {
     if (invoice.Customer == "Joe")
     {
         return 10m;
     }
     return 0m;
 }
 public decimal Apply(Invoice invoice)
 {
     if (invoice.State == "KS")
     {
         return invoice.Total * 0.1m;
     }
     return 0m;
 }
        public void Approve(Invoice invoice)
        {
            Console.WriteLine("Starting approval for " + invoice.Customer);

            _inner.Approve(invoice);

            Console.WriteLine("Finished approval for " + invoice.Customer);
        }
 public decimal Apply(Invoice invoice)
 {
     if (invoice.Total > 1000m)
     {
         return 50m;
     }
     return 0m;
 }
        public void Approve(Invoice invoice)
        {
            decimal discount = _discounters
                .Aggregate(0m, (current, discounter) 
                    => current + discounter.Apply(invoice));

            invoice.ApprovedAmount = invoice.Total - discount;

            _emailSender.Send("Approved " + invoice.ApprovedAmount + " for " + invoice.Customer);
        }