public override bool Equals(Object obj)
        {
            // Check for null values and compare run-time types.
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            HourlyPosition p = (HourlyPosition)obj;

            return((_hour == p.Hour) && (_amount == p.Amount));
        }
Esempio n. 2
0
        //Take the list of powertrades and aggregate the volume into the hourly positions
        private Dictionary <int, HourlyPosition> GetPosition(IEnumerable <PowerTrade> powerTrades)
        {
            var hourlyPositions = new Dictionary <int, HourlyPosition>();

            //first initialize the dictionary to 0
            for (int i = 1; i <= 24; i++)
            {
                var addHourlyPosition = new HourlyPosition(i, 0);
                hourlyPositions.Add(addHourlyPosition.Hour, addHourlyPosition);
            }
            //now cycle through the powertrades and update the positions by hour
            foreach (PowerTrade trade in powerTrades)
            {
                foreach (PowerPeriod period in trade.Periods)
                {
                    var setPosition = hourlyPositions[period.Period];
                    setPosition.Amount += Convert.ToDecimal(period.Volume);
                }
            }
            return(hourlyPositions);
        }