コード例 #1
0
 public void CalculateDailyEmission(EmissionsFactor emissionsFactor)
 {
     foreach (var day in Generation)
     {
         day.Emission = day.Energy * this.EmissionsRating * emissionsFactor.Medium;
     }
 }
コード例 #2
0
        public IEnumerable <Day> GetEmissionDays(EmissionsFactor emissionsFactor)
        {
            var days       = new List <Day>();
            var generators = GetAllGenerators().Where(x => x is ICoalGenerator || x is IGasGenerator);

            foreach (var generator in generators)
            {
                // Calculate emissions.
                if (generator is ICoalGenerator)
                {
                    ((ICoalGenerator)generator).CalculateDailyEmission(emissionsFactor);
                }
                else if (generator is IGasGenerator)
                {
                    ((IGasGenerator)generator).CalculateDailyEmission(emissionsFactor);
                }

                days.AddRange(generator.Generation.Select(x => new Day()
                {
                    Date     = x.Date,
                    Energy   = x.Energy,
                    Name     = generator.Name,
                    Price    = x.Price,
                    Emission = x.Emission
                }));
            }

            return(days);
        }