本文整理匯總了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;
}