本文整理汇总了C#中RecurrencePattern.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# RecurrencePattern.GetService方法的具体用法?C# RecurrencePattern.GetService怎么用?C# RecurrencePattern.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecurrencePattern
的用法示例。
在下文中一共展示了RecurrencePattern.GetService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecurrencePattern2
public void RecurrencePattern2()
{
// NOTE: evaluators are generally not meant to be used directly like this.
// However, this does make a good test to ensure they behave as they should.
RecurrencePattern pattern = new RecurrencePattern("FREQ=MINUTELY;INTERVAL=1");
CultureInfo us = CultureInfo.CreateSpecificCulture("en-US");
iCalDateTime startDate = new iCalDateTime(DateTime.Parse("3/31/2008 12:00:10 AM", us));
iCalDateTime fromDate = new iCalDateTime(DateTime.Parse("4/1/2008 10:08:10 AM", us));
iCalDateTime toDate = new iCalDateTime(DateTime.Parse("4/1/2008 10:43:23 AM", us));
IEvaluator evaluator = pattern.GetService(typeof(IEvaluator)) as IEvaluator;
Assert.IsNotNull(evaluator);
IList<IPeriod> occurrences = evaluator.Evaluate(
startDate,
DateUtil.SimpleDateTimeToMatch(fromDate, startDate),
DateUtil.SimpleDateTimeToMatch(toDate, startDate),
false);
Assert.AreNotEqual(0, occurrences.Count);
}
示例2: Test4
public void Test4()
{
IRecurrencePattern rpattern = new RecurrencePattern();
rpattern.ByDay.Add(new WeekDay(DayOfWeek.Saturday));
rpattern.ByDay.Add(new WeekDay(DayOfWeek.Sunday));
rpattern.Frequency = FrequencyType.Weekly;
IDateTime evtStart = new iCalDateTime(2006, 12, 1);
IDateTime evtEnd = new iCalDateTime(2007, 1, 1);
IEvaluator evaluator = rpattern.GetService(typeof(IEvaluator)) as IEvaluator;
Assert.IsNotNull(evaluator);
// Add the exception dates
IList<IPeriod> periods = evaluator.Evaluate(
evtStart,
DateUtil.GetSimpleDateTimeData(evtStart),
DateUtil.SimpleDateTimeToMatch(evtEnd, evtStart),
false);
Assert.AreEqual(10, periods.Count);
Assert.AreEqual(2, periods[0].StartTime.Day);
Assert.AreEqual(3, periods[1].StartTime.Day);
Assert.AreEqual(9, periods[2].StartTime.Day);
Assert.AreEqual(10, periods[3].StartTime.Day);
Assert.AreEqual(16, periods[4].StartTime.Day);
Assert.AreEqual(17, periods[5].StartTime.Day);
Assert.AreEqual(23, periods[6].StartTime.Day);
Assert.AreEqual(24, periods[7].StartTime.Day);
Assert.AreEqual(30, periods[8].StartTime.Day);
Assert.AreEqual(31, periods[9].StartTime.Day);
}
示例3: RecurrencePattern1
public void RecurrencePattern1()
{
// NOTE: evaluators are not generally meant to be used directly like this.
// However, this does make a good test to ensure they behave as they should.
IRecurrencePattern pattern = new RecurrencePattern("FREQ=SECONDLY;INTERVAL=10");
pattern.RestrictionType = RecurrenceRestrictionType.NoRestriction;
CultureInfo us = CultureInfo.CreateSpecificCulture("en-US");
iCalDateTime startDate = new iCalDateTime(DateTime.Parse("3/30/08 11:59:40 PM", us));
iCalDateTime fromDate = new iCalDateTime(DateTime.Parse("3/30/08 11:59:40 PM", us));
iCalDateTime toDate = new iCalDateTime(DateTime.Parse("3/31/08 12:00:11 AM", us));
IEvaluator evaluator = pattern.GetService(typeof(IEvaluator)) as IEvaluator;
Assert.IsNotNull(evaluator);
IList<IPeriod> occurrences = evaluator.Evaluate(
startDate,
DateUtil.SimpleDateTimeToMatch(fromDate, startDate),
DateUtil.SimpleDateTimeToMatch(toDate, startDate),
false);
Assert.AreEqual(4, occurrences.Count);
Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/30/08 11:59:40 PM", us)), occurrences[0].StartTime);
Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/30/08 11:59:50 PM", us)), occurrences[1].StartTime);
Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/31/08 12:00:00 AM", us)), occurrences[2].StartTime);
Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/31/08 12:00:10 AM", us)), occurrences[3].StartTime);
}