Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers.PolicyHelpers.GetRetentionDurationInYears C# (CSharp) Method

GetRetentionDurationInYears() private static method

private static GetRetentionDurationInYears ( Microsoft.Azure.Management.RecoveryServices.Backup.Models retentionDuration ) : int
retentionDuration Microsoft.Azure.Management.RecoveryServices.Backup.Models
return int
        private static int GetRetentionDurationInYears(ServiceClientModel.RetentionDuration retentionDuration)
        {
            int yearsCount = 0;

            switch (retentionDuration.DurationType)
            {
                case ServiceClientModel.RetentionDurationType.Days:
                    yearsCount = retentionDuration.Count / PolicyConstants.NumOfDaysInYear;
                    break;

                case ServiceClientModel.RetentionDurationType.Weeks:
                    yearsCount = retentionDuration.Count / PolicyConstants.NumOfWeeksInYear;
                    break;

                case ServiceClientModel.RetentionDurationType.Months:
                    yearsCount = retentionDuration.Count / PolicyConstants.NumOfMonthsInYear;
                    break;

                case ServiceClientModel.RetentionDurationType.Years:
                    yearsCount = retentionDuration.Count;
                    break;

                default:
                    throw new ArgumentException(Resources.InvalidDurationTypeException,
                                                retentionDuration.DurationType.ToString());
            }

            return yearsCount;
        }