public void TestCount() { IRRuleTokenContainer tokenContainer = tokenizer.Tokenize("FREQ=DAILY;COUNT=1"); Assert.AreEqual(2, tokenContainer.RuleCount()); Assert.NotNull(tokenContainer.GetCount()); Assert.AreEqual(1, (int)tokenContainer.GetCount().GetValue()); }
private void EnsureSingleExistenceUntilCount(IRRuleTokenContainer tokenContainer) { if (tokenContainer.GetUntil() != null && tokenContainer.GetCount() != null) { throw new RRuleValidationException("RRule part 'UNTIL' and 'COUNT' are present at the same time"); } }
public string BuildText(IRRuleTokenContainer tokenContainer) { var resultString = BuildFrequency(tokenContainer); var freqValue = (FreqToken.FreqValue)tokenContainer.GetFreq().GetValue(); if (freqValue == FreqToken.FreqValue.WEEKLY) { resultString += " " + BuildWeeklyDays(tokenContainer); } else if (freqValue == FreqToken.FreqValue.MONTHLY && tokenContainer.GetByMontDay() != null) { resultString += " " + BuildMonthlyOnDay(tokenContainer); } else if (freqValue == FreqToken.FreqValue.MONTHLY && tokenContainer.GetBySetPos() != null && tokenContainer.GetByDay() != null) { resultString += " " + BuildMonthlyOnNumberedDay(tokenContainer); } else if (freqValue == FreqToken.FreqValue.YEARLY && tokenContainer.GetByMonth() != null && tokenContainer.GetByMontDay() != null) { resultString += " " + BuildYearlyOnDay(tokenContainer); } else if (freqValue == FreqToken.FreqValue.YEARLY && tokenContainer.GetByDay() != null && tokenContainer.GetBySetPos() != null && tokenContainer.GetByMonth() != null) { resultString += " " + BuildYearlyOnNumbered(tokenContainer); } if (tokenContainer.GetStart() != null) { var ending = _buildStartDate(tokenContainer); if (ending != null) { resultString += ", " + ending; } } // Endings if (tokenContainer.GetUntil() != null) { var ending = _buildUntilDateEnding(tokenContainer); if (ending != null) { resultString += ", " + ending; } } else if (tokenContainer.GetCount() != null) { var ending = BuildCountEnding(tokenContainer); if (ending != null) { resultString += ", " + ending; } } return(CapitalizeFirstLetter(resultString.Trim())); }
public void Merge(IRRuleTokenContainer tokenContainer) { if (tokenContainer.GetFreq() != null && GetFreq() == null) { AddOrUpdateToken(tokenContainer.GetFreq()); } if (tokenContainer.GetUntil() != null && GetUntil() == null) { AddOrUpdateToken(tokenContainer.GetUntil()); } if (tokenContainer.GetCount() != null && GetCount() == null) { AddOrUpdateToken(tokenContainer.GetCount()); } if (tokenContainer.GetInterval() != null && GetInterval() == null) { AddOrUpdateToken(tokenContainer.GetInterval()); } if (tokenContainer.GetByDay() != null && GetByDay() == null) { AddOrUpdateToken(tokenContainer.GetByDay()); } if (tokenContainer.GetByMontDay() != null && GetByMontDay() == null) { AddOrUpdateToken(tokenContainer.GetByMontDay()); } if (tokenContainer.GetByMonth() != null && GetByMonth() == null) { AddOrUpdateToken(tokenContainer.GetByMonth()); } if (tokenContainer.GetBySetPos() != null && GetBySetPos() == null) { AddOrUpdateToken(tokenContainer.GetBySetPos()); } }
private string BuildCountEnding(IRRuleTokenContainer pTokenContainer) { var countToken = pTokenContainer.GetCount(); if (countToken == null) { return(null); } if (((int)countToken.GetValue()) == 1) { return(null); } return($"{countToken.GetValue()} {_fragmentTranslator.GetTranslatedFragment(ETranslationFragment.TIMES)}"); }