/// <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; }
/// <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; }