Inheritance: AzureRMBackupRetentionPolicy
        private static CSMYearlyRetentionSchedule ConvertToCSMYearlyRetentionObject(AzureBackupYearlyRetentionPolicy retentionPolicy, IList<DateTime> RetentionTimes)
        {
            CSMYearlyRetentionSchedule csmYearlyRetention = new CSMYearlyRetentionSchedule();

            if (retentionPolicy.RetentionFormat == RetentionFormat.Daily)
            {
                csmYearlyRetention.RetentionScheduleType = RetentionScheduleFormat.Daily;
                csmYearlyRetention.RetentionScheduleDaily = new CSMDailyRetentionFormat();
                csmYearlyRetention.RetentionScheduleDaily.DaysOfTheMonth = ConvertToCSMDayList(retentionPolicy.DaysOfMonth);
            }

            else if (retentionPolicy.RetentionFormat == RetentionFormat.Weekly)
            {
                csmYearlyRetention.RetentionScheduleWeekly = new CSMWeeklyRetentionFormat();
                csmYearlyRetention.RetentionScheduleType = RetentionScheduleFormat.Weekly;
                csmYearlyRetention.RetentionScheduleWeekly.DaysOfTheWeek = retentionPolicy.DaysOfWeek;
                csmYearlyRetention.RetentionScheduleWeekly.WeeksOfTheMonth = retentionPolicy.WeekNumber;
            }

            csmYearlyRetention.CSMRetentionDuration = new CSMRetentionDuration();
            csmYearlyRetention.CSMRetentionDuration.Count = retentionPolicy.Retention;
            csmYearlyRetention.CSMRetentionDuration.DurationType = RetentionDurationType.Years;
            csmYearlyRetention.RetentionTimes = RetentionTimes;
            csmYearlyRetention.MonthsOfYear = retentionPolicy.MonthsOfYear;

            return csmYearlyRetention;
        }
        private static void ValidateYearlyRetention(AzureBackupYearlyRetentionPolicy yearlyRetention)
        {
            if (yearlyRetention.Retention < MinRetention || yearlyRetention.Retention > MaxRetentionInYears)
            {
                var exception = new ArgumentException(string.Format(Resources.YearlyRetentionPolicyValueException, MinRetention, MaxRetentionInYears));
                throw exception;
            }

            if(yearlyRetention.MonthsOfYear == null || yearlyRetention.MonthsOfYear.Count == 0)
            {
                var exception = new ArgumentException(Resources.YearlyRetentionPolicyMonthOfYearParamException);
                throw exception;
            }

            if (yearlyRetention.RetentionFormat == RetentionFormat.Daily)
            {
                if (yearlyRetention.DaysOfMonth == null || yearlyRetention.DaysOfMonth.Count == 0)
                {
                    var exception = new ArgumentException(Resources.YearlyRetentionPolicyDaysOfMonthParamException);
                    throw exception;
                }

                if (yearlyRetention.DaysOfWeek != null || yearlyRetention.WeekNumber != null)
                {
                    var exception = new ArgumentException(Resources.YearlyRetentionPolicyDaysOfWeekParamException);
                    throw exception;
                }
            }

            if (yearlyRetention.RetentionFormat == RetentionFormat.Weekly)
            {
                if (yearlyRetention.DaysOfWeek == null || yearlyRetention.DaysOfWeek.Count == 0)
                {
                    var exception = new ArgumentException(Resources.YearlyRetentionPolicyDaysOfWeekInWeeksFormatParamException);
                    throw exception;
                }

                if (yearlyRetention.WeekNumber == null || yearlyRetention.WeekNumber.Count == 0)
                {
                    var exception = new ArgumentException(Resources.YearlyRetentionPolicyWeekNumParamException);
                    throw exception;
                }

                if (yearlyRetention.DaysOfMonth != null)
                {
                    var exception = new ArgumentException(Resources.YearlyRetentionPolicyDaysOfMonthInWeekFormatException);
                    throw exception;
                }
            }
        }
        private static AzureBackupYearlyRetentionPolicy ConvertToPowershellYearlyRetentionObject(CSMYearlyRetentionSchedule YearlySchedule)
        {
            if (YearlySchedule == null)
                return null;
            AzureBackupYearlyRetentionPolicy yearlyRetention = null;

            List<Month> monthOfTheYearList = ConvertToPowershellMonthsOfYearList(YearlySchedule.MonthsOfYear);

            RetentionFormat retentionFormat = (RetentionFormat)Enum.Parse(typeof(RetentionFormat), YearlySchedule.RetentionScheduleType.ToString(), true);
            if (retentionFormat == RetentionFormat.Daily)
            {
                List<string> dayList = ConvertToPowershellDayList(YearlySchedule.RetentionScheduleDaily.DaysOfTheMonth);
                yearlyRetention = new AzureBackupYearlyRetentionPolicy("Yearly", YearlySchedule.CSMRetentionDuration.Count,
                monthOfTheYearList, retentionFormat, dayList, null, null);
            }
            else if (retentionFormat == RetentionFormat.Weekly)
            {
                List<WeekNumber> weekNumberList = ConvertToPowershellWeekNumberList(YearlySchedule.RetentionScheduleWeekly);
                List<DayOfWeek> dayOfWeekList = ConvertToPowershellWeekDaysList(YearlySchedule.RetentionScheduleWeekly);
                yearlyRetention = new AzureBackupYearlyRetentionPolicy("Yearly", YearlySchedule.CSMRetentionDuration.Count,
                 monthOfTheYearList, retentionFormat, null, weekNumberList, dayOfWeekList);
            }

            yearlyRetention.RetentionTimes = YearlySchedule.RetentionTimes;
            return yearlyRetention;
        }
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                base.ExecuteCmdlet();
                if (DailyRetention != false)
                {
                    AzureRMBackupRetentionPolicy retentionPolicy = new AzureBackupDailyRetentionPolicy(RetentionType.Daily.ToString(), Retention);
                    ProtectionPolicyHelpers.ValidateRetentionPolicy(new List<AzureRMBackupRetentionPolicy> { retentionPolicy });
                    WriteObject(retentionPolicy);
                }

                if (WeeklyRetention != false)
                {
                    List<DayOfWeek> daysofWeekList = ConvertDaysOfWeek(DaysOfWeek);
                    AzureRMBackupRetentionPolicy retentionPolicy = new AzureBackupWeeklyRetentionPolicy(RetentionType.Weekly.ToString(), Retention, daysofWeekList);
                    ProtectionPolicyHelpers.ValidateRetentionPolicy(new List<AzureRMBackupRetentionPolicy> { retentionPolicy });
                    WriteObject(retentionPolicy);
                }

                if (MonthlyRetentionInDailyFormat != false)
                {
                    AzureRMBackupRetentionPolicy retentionPolicy = new AzureBackupMonthlyRetentionPolicy(RetentionType.Monthly.ToString(), Retention, RetentionFormat.Daily, DaysOfMonth,
                        null, null);
                    ProtectionPolicyHelpers.ValidateRetentionPolicy(new List<AzureRMBackupRetentionPolicy> { retentionPolicy });
                    WriteObject(retentionPolicy);
                }

                if (MonthlyRetentionInWeeklyFormat != false)
                {
                    List<DayOfWeek> daysofWeekList = ConvertDaysOfWeek(DaysOfWeek);
                    List<WeekNumber> weekNumbers = ConvertWeekNumbers(WeekNumber);
                    AzureRMBackupRetentionPolicy retentionPolicy = new AzureBackupMonthlyRetentionPolicy(RetentionType.Monthly.ToString(), Retention, RetentionFormat.Weekly, DaysOfMonth,
                        weekNumbers, daysofWeekList);

                    ProtectionPolicyHelpers.ValidateRetentionPolicy(new List<AzureRMBackupRetentionPolicy> { retentionPolicy });

                    WriteObject(retentionPolicy);
                }

                if (YearlyRetentionInDailyFormat != false)
                {
                    List<Month> monthsOfYear = ConvertMonthsOfYear(MonthsOfYear);
                    AzureRMBackupRetentionPolicy retentionPolicy = new AzureBackupYearlyRetentionPolicy(RetentionType.Yearly.ToString(), Retention, monthsOfYear, RetentionFormat.Daily,
                        DaysOfMonth, null, null);

                    ProtectionPolicyHelpers.ValidateRetentionPolicy(new List<AzureRMBackupRetentionPolicy> { retentionPolicy });

                    WriteObject(retentionPolicy);
                }

                if (YearlyRetentionInWeeklyFormat != false)
                {
                    List<DayOfWeek> daysofWeekList = ConvertDaysOfWeek(DaysOfWeek);
                    List<WeekNumber> weekNumbers = ConvertWeekNumbers(WeekNumber);
                    List<Month> monthsOfYear = ConvertMonthsOfYear(MonthsOfYear);
                    AzureRMBackupRetentionPolicy retentionPolicy = new AzureBackupYearlyRetentionPolicy(RetentionType.Yearly.ToString(), Retention, monthsOfYear,
                        RetentionFormat.Weekly, DaysOfMonth, weekNumbers, daysofWeekList);

                    ProtectionPolicyHelpers.ValidateRetentionPolicy(new List<AzureRMBackupRetentionPolicy> { retentionPolicy });

                    WriteObject(retentionPolicy);
                }
            });
        }