public override void Validate() { base.Validate(); if (DurationCountInYears <= 0 || DurationCountInYears > PolicyConstants.MaxAllowedRetentionDurationCount) { throw new ArgumentException(Resources.RetentionDurationCountInvalidException); } if (MonthsOfYear == null || MonthsOfYear.Count == 0 || MonthsOfYear.Count != MonthsOfYear.Distinct().Count()) { throw new ArgumentException(Resources.YearlyScheduleMonthsOfYearException); } if (RetentionScheduleFormatType == RetentionScheduleFormat.Daily) { if (RetentionScheduleDaily == null) { throw new ArgumentException(Resources.MonthlyYearlyRetentionDailySchedulePolicyNULLException); } RetentionScheduleDaily.Validate(); } if (RetentionScheduleFormatType == RetentionScheduleFormat.Weekly) { if (RetentionScheduleWeekly == null) { throw new ArgumentException(Resources.MonthlyYearlyRetentionWeeklySchedulePolicyNULLException); } RetentionScheduleWeekly.Validate(); } }
public override void Validate() { base.Validate(); int MinDurationCountInYears = 1, MaxDurationCountInYears = PolicyConstants.MaxAllowedRetentionDurationCountYearly; if (BackupManagementType == Management.RecoveryServices.Backup.Models.BackupManagementType.AzureStorage) { MinDurationCountInYears = PolicyConstants.AfsYearlyRetentionMin; MaxDurationCountInYears = PolicyConstants.AfsYearlyRetentionMax; } if (DurationCountInYears < MinDurationCountInYears || DurationCountInYears > MaxDurationCountInYears) { throw new ArgumentException(Resources.RetentionDurationCountInvalidException); } if (MonthsOfYear == null || MonthsOfYear.Count == 0 || MonthsOfYear.Count != MonthsOfYear.Distinct().Count()) { throw new ArgumentException(Resources.YearlyScheduleMonthsOfYearException); } if (RetentionScheduleFormatType == RetentionScheduleFormat.Daily) { if (RetentionScheduleDaily == null) { throw new ArgumentException(Resources.MonthlyYearlyRetentionDailySchedulePolicyNULLException); } RetentionScheduleDaily.Validate(); } if (RetentionScheduleFormatType == RetentionScheduleFormat.Weekly) { if (RetentionScheduleWeekly == null) { throw new ArgumentException(Resources.MonthlyYearlyRetentionWeeklySchedulePolicyNULLException); } RetentionScheduleWeekly.Validate(); } }