Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class LongTermRetentionPolicy : RetentionPolicyBase
public bool IsMonthlyScheduleEnabled { get; set; }
public bool IsYearlyScheduleEnabled { get; set; }
public DailyRetentionSchedule DailySchedule { get; set; }
public WeeklyRetentionSchedule WeeklySchedule { get; set; }
public WeeklyRetentionSchedule WeeklySchedule { get; set; }
public MonthlyRetentionSchedule MonthlySchedule { get; set; }
public YearlyRetentionSchedule YearlySchedule { get; set; }

Expand Down Expand Up @@ -98,8 +98,8 @@ public override void Validate()
{
YearlySchedule.Validate();
}
}
}
}
}

public override string ToString()
{
Expand All @@ -114,7 +114,7 @@ public override string ToString()
YearlySchedule == null ? "NULL" : YearlySchedule.ToString());
}
}

/// <summary>
/// Base class for retention schedule.
/// </summary>
Expand All @@ -127,15 +127,15 @@ public virtual void Validate()
if (RetentionTimes == null || RetentionTimes.Count == 0 || RetentionTimes.Count != 1)
{
throw new ArgumentException(Resources.InvalidRetentionTimesInPolicyException);
}
}
}
}

public override string ToString()
{
return string.Format("RetentionTimes: {0}", TraceUtils.GetString(RetentionTimes));
return string.Format("RetentionTimes: {0}", TraceUtils.GetString(RetentionTimes));
}
}

/// <summary>
/// Daily rentention schedule.
/// </summary>
Expand All @@ -149,18 +149,17 @@ public override void Validate()
if (DurationCountInDays <= 0 || DurationCountInDays > PolicyConstants.MaxAllowedRetentionDurationCount)
{
throw new ArgumentException(Resources.RetentionDurationCountInvalidException);
}
}

base.Validate();
}

public override string ToString()
{
return string.Format("DurationCountInDays: {0}, {1}",
DurationCountInDays, base.ToString());
return string.Format("DurationCountInDays: {0}, {1}", DurationCountInDays, base.ToString());
}
}

/// <summary>
/// Weekly rentention schedule.
/// </summary>
Expand All @@ -183,16 +182,15 @@ public override void Validate()
}

base.Validate();
}
}

public override string ToString()
{
return string.Format("DaysOfTheWeek: {0}, {1}",
TraceUtils.GetString(DaysOfTheWeek),
base.ToString());
return string.Format("DurationCountInWeeks: {0}, DaysOfTheWeek: {1}, {2}",
DurationCountInWeeks, TraceUtils.GetString(DaysOfTheWeek), base.ToString());
}
}

/// <summary>
/// Monthly rentention schedule.
/// </summary>
Expand All @@ -208,7 +206,7 @@ public class MonthlyRetentionSchedule : RetentionScheduleBase

public MonthlyRetentionSchedule()
: base()
{
{
}

public override void Validate()
Expand All @@ -219,7 +217,7 @@ public override void Validate()
{
throw new ArgumentException(Resources.RetentionDurationCountInvalidException);
}

if (RetentionScheduleFormatType == RetentionScheduleFormat.Daily)
{
if (RetentionScheduleDaily == null)
Expand All @@ -234,23 +232,24 @@ public override void Validate()
{
if (RetentionScheduleWeekly == null)
{
throw new ArgumentException(Resources.MonthlyYearlyRetentionWeeklySchedulePolicyNULLException);
throw new ArgumentException(Resources.MonthlyYearlyRetentionWeeklySchedulePolicyNULLException);
}

RetentionScheduleWeekly.Validate();
}
}
}

public override string ToString()
{
return string.Format("RetentionScheduleType:{0}, {1}, RetentionScheduleDaily:{2}," +
"RetentionScheduleWeekly:{3}, {4}", RetentionScheduleFormatType, base.ToString(),
return string.Format("DurationCountInMonths:{0}, RetentionScheduleType:{1}, {2}, RetentionScheduleDaily:{3}," +
"RetentionScheduleWeekly:{4}, {5}",
DurationCountInMonths, RetentionScheduleFormatType, base.ToString(),
RetentionScheduleDaily == null ? "NULL" : RetentionScheduleDaily.ToString(),
RetentionScheduleWeekly == null ? "NULL" : RetentionScheduleWeekly.ToString(),
base.ToString());
}
}

/// <summary>
/// Yearly rentention schedule.
/// </summary>
Expand All @@ -261,13 +260,13 @@ public class YearlyRetentionSchedule : RetentionScheduleBase

public List<Month> MonthsOfYear { get; set; }
public DailyRetentionFormat RetentionScheduleDaily { get; set; }

public WeeklyRetentionFormat RetentionScheduleWeekly { get; set; }

public YearlyRetentionSchedule()
: base()
{

}

public override void Validate()
Expand All @@ -278,12 +277,12 @@ public override void Validate()
{
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)
Expand All @@ -303,20 +302,19 @@ public override void Validate()

RetentionScheduleWeekly.Validate();
}
}
}

public override string ToString()
{
return string.Format("RetentionScheduleType:{0}, {1}, RetentionScheduleDaily:{2}," +
"RetentionScheduleWeekly:{3}, MonthsOfYear: {4}, {5}",
RetentionScheduleFormatType.ToString(),
base.ToString(),
return string.Format("DurationCountInYears:{0}, RetentionScheduleType:{1}, {2}, RetentionScheduleDaily:{3}," +
"RetentionScheduleWeekly:{4}, MonthsOfYear: {5}, {6}",
DurationCountInYears, RetentionScheduleFormatType.ToString(), base.ToString(),
RetentionScheduleDaily == null ? "NULL" : RetentionScheduleDaily.ToString(),
RetentionScheduleWeekly == null ? "NULL" : RetentionScheduleWeekly.ToString(),
TraceUtils.GetString<Month>(MonthsOfYear), base.ToString());
}
}

/// <summary>
/// Daily rentention format.
/// </summary>
Expand All @@ -343,13 +341,13 @@ public void Validate()
foreach (Day day in DaysOfTheMonth)
{
day.Validate();
if(day.IsLast)
if (day.IsLast)
{
countOfIsLast++;
}
}

if(countOfIsLast > 1)
if (countOfIsLast > 1)
{
throw new ArgumentException(Resources.InvalidDayInDaysOfMonthOfMonthlyYearlyRetentionPolicyException);
}
Expand All @@ -360,7 +358,7 @@ public override string ToString()
return string.Format("DaysOfTheMonth:{0}", TraceUtils.GetString(DaysOfTheMonth));
}
}

/// <summary>
/// Weekly rentention format.
/// </summary>
Expand All @@ -376,13 +374,13 @@ public void Validate()
DaysOfTheWeek.Count != DaysOfTheWeek.Distinct().Count())
{
throw new ArgumentException(Resources.InvalidDaysOfWeekInMonthlyYearlyRetentionPolicyException);
}
}

if (WeeksOfTheMonth == null || WeeksOfTheMonth.Count == 0 ||
WeeksOfTheMonth.Count != WeeksOfTheMonth.Distinct().Count())
{
throw new ArgumentException(Resources.InvalidWeeksOfMonthInMonthlyYearlyRetentionPolicyException);
}
}
}

public override string ToString()
Expand Down Expand Up @@ -419,5 +417,5 @@ public override string ToString()
{
return string.Format("Date:{0}, IsLast:{1}", Date, IsLast);
}
}
}
}