main
 1namespace domain
 2{
 3  using System;
 4  using System.Collections.Generic;
 5  using System.Linq;
 6  using utility;
 7
 8  public class ProductionSchedule : IVisitable<IWell>
 9  {
10    ICollection<IWell> wells = new List<IWell>();
11
12    public void Include(IWell well)
13    {
14      wells.Add(well);
15    }
16
17    public IQuantity EstimatedGrossProductionFor<Commodity>(Month month) where Commodity : ICommodity, new()
18    {
19      return wells.Select(well => well.GrossProductionFor<Commodity>(month)).Sum<BOED>();
20    }
21
22    public IQuantity EstimatedNetProductionFor<Commodity>(Month month) where Commodity : ICommodity, new()
23    {
24      return wells.Select(well => well.NetProductionFor<Commodity>(month)).Sum<BOED>();
25    }
26
27    public void Accept(IVisitor<IWell> visitor )
28    {
29      Accept(visitor.Visit);
30    }
31
32    void Accept(Action<IWell> visitor )
33    {
34      wells.Each(well =>
35      {
36        visitor(well);
37      });
38    }
39  }
40}