Example #1
0
        public FreeToPlayPeriod AddFreeToPlayPeriod(DateTime begin, DateTime end, DateTime now)
        {
            // Do not allow past periods to be added
            if (end <= now)
            {
                Trace.TraceInformation($"End {end} is before now {now}");
                return null;
            }

            FreeToPlayPeriod freeToPlayPeriod = new FreeToPlayPeriod(begin, end);
            FreeToPlayPeriod intersectingfreeToPlayPeriod = FreeToPlayPeriods.FirstOrDefault(freeToPlayPeriod.Intersects);

            // Periods are to be mutually exclusive to make it easier to identify which one is being applied
            if (intersectingfreeToPlayPeriod != null)
            {
                Trace.TraceInformation($"Found intersecting periods {freeToPlayPeriod} and {intersectingfreeToPlayPeriod} for {Name}");
                return null;
            }

            _freeToPlayPeriods.Add(freeToPlayPeriod);
            Trace.TraceInformation($"Added {freeToPlayPeriod} for {Name}");
            return freeToPlayPeriod;
        }
Example #2
0
 public void Remove(FreeToPlayPeriod freeToPlayPeriod)
 {
     _freeToPlayPeriods.Remove(freeToPlayPeriod);
     Trace.TraceInformation($"Removed {freeToPlayPeriod} for {Name}");
 }
Example #3
0
 // Indicates whether the period intersects with another period
 public bool Intersects(FreeToPlayPeriod freeToPlayPeriod) => Begin < freeToPlayPeriod.End && freeToPlayPeriod.Begin < End;