本文整理汇总了C#中ScheduleWidget.ScheduledEvents.Schedule.zInternalGetEndDateBasedOnNumberOfOccurrences方法的典型用法代码示例。如果您正苦于以下问题:C# Schedule.zInternalGetEndDateBasedOnNumberOfOccurrences方法的具体用法?C# Schedule.zInternalGetEndDateBasedOnNumberOfOccurrences怎么用?C# Schedule.zInternalGetEndDateBasedOnNumberOfOccurrences使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScheduleWidget.ScheduledEvents.Schedule
的用法示例。
在下文中一共展示了Schedule.zInternalGetEndDateBasedOnNumberOfOccurrences方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetEndDateWithNumberOfOccurrences
/// <summary>
/// SetEndDateWithNumberOfOccurrences,
/// This will use the currently defined event schedule, to choose and set an
/// EndDateTime that will limit the event to a fixed maximum number of occurrences.
/// Calling this function will override any previously set EndDateTime.
///
/// All other desired event parameters should be set before this function is called.
/// Previously set variables should include at minimum, a StartDateTime, and a Frequency.
///
/// The reason this sets a "maximum" number of occurrences, is that the number of
/// actual occurrences can be reduced by excluding occurrence dates from a Schedule
/// instance. Changing the exclusions will not change the EndDateTime.
///
/// The supplied maximumNumberOfOccurrences value is recorded for informational
/// purposes only. Only the EndDateTime is used by the Event and Schedule calculations.
///
/// Setting this to null will clear the NumberOfOccurrencesThatWasLastSet variable, but will
/// not change the EndDateTime value.
/// </summary>
public void SetEndDateWithNumberOfOccurrences(int? numberOfOccurrences)
{
// If the supplied parameter is null, clear the last set number of occurrences and return.
if (numberOfOccurrences == null)
{
NumberOfOccurrencesThatWasLastSet = null;
return;
}
// Validate the input parameters.
if (numberOfOccurrences < 1)
throw new Exception("SetEndDateTimeForMaximumNumberOfOccurrences(), " +
"numberOfOccurrences cannot be less than one.");
// Calculate and set the appropriate end date.
Schedule schedule = new Schedule(this);
EndDateTime = schedule.zInternalGetEndDateBasedOnNumberOfOccurrences((int)numberOfOccurrences);
// Store the last set number of occurrences, for future reference by the user.
NumberOfOccurrencesThatWasLastSet = numberOfOccurrences;
}