Exemple #1
0
        public override bool IsMatch(DateTime day)
        {
            if (Nth == 0)
            {
                throw new InvalidOperationException("Nth rule can't count to zero");
            }
            //first, the current day must match the rule (e.g. 2nd monday after xxx must be a Monday!)
            if (!NthRule.IsMatch(day))
            {
                return(false);
            }

            var ruleWithAlternatives = NthRule as IHasAlternateRules;
            var nthRules             = ruleWithAlternatives != null ? ruleWithAlternatives.Rules : new[] { NthRule };

            var searchDays = nthRules.SelectMany(crtRule => GetCandidateDays(day, crtRule))
                             .Distinct() // skip duplicate days
            ;

            return(searchDays.Any(d => ReferencedRule.IsMatch(d))); //in the search interval, there's a day matching the guiding rule
        }
 public override bool IsMatch(DateTime day)
 {
     return(StartDate <= day.Date && day.Date <= EndDate &&
            ReferencedRule.IsMatch(day));
 }
Exemple #3
0
 public override bool IsMatch(DateTime day)
 {
     return(day >= StartDate && ReferencedRule.IsMatch(day));
 }
 public override bool IsMatch(DateTime day)
 {
     return(ReferencedRule.IsMatch(day - TimeSpan.FromDays(Nth)));
 }
Exemple #5
0
 public override bool IsMatch(DateTime day)
 {
     return(!ReferencedRule.IsMatch(day));
 }