/// <summary>
            /// Assumes there's at least one week day selected if using weekly
            /// </summary>
            /// <param name="viewModel"></param>
            /// <param name="userPickedStartDate"></param>
            public DateOccurrenceEnumerator(RecurrenceControlViewModel viewModel, DateTime userPickedStartDate)
            {
                _viewModel        = viewModel;
                _repeatInterval   = viewModel.GetRepeatIntervalAsNumber();
                _sortedRepeatDays = viewModel.GetSelectedDaysOfWeek();

                // Get the actual start date
                _startDate = viewModel.GetStartDate(userPickedStartDate);
            }
            public bool MoveNext()
            {
                // If limiting by occurrences and we've reached the limit
                if (_viewModel.IsEndOccurrencesChecked && _countSoFar >= _viewModel.GetEndOccurrencesAsNumber())
                {
                    return(false);
                }

                DateTime prospectiveNextDate;

                // If first
                if (_countSoFar == 0)
                {
                    prospectiveNextDate = _startDate;
                }
                else
                {
                    switch (_viewModel.SelectedRepeatOption)
                    {
                    case RepeatOptions.Daily:
                        prospectiveNextDate = _startDate.AddDays(_repeatInterval * _countSoFar).Date;
                        break;

                    case RepeatOptions.Weekly:

                        // If only one day repeating on, that's easy
                        if (_sortedRepeatDays.Length == 1)
                        {
                            prospectiveNextDate = Current.AddDays(_repeatInterval * 7);
                        }
                        else
                        {
                            DateTime value;

                            // If not repeating every week and we're on the last day, jump ahead
                            // Note that this would be slightly wrong in countries where the first day isn't Sunday
                            if (_repeatInterval > 1 && Current.DayOfWeek == _sortedRepeatDays.Last())
                            {
                                value = Current.AddDays(8);
                            }
                            else
                            {
                                // Otherwise we just jump ahead 1 and then look for the next
                                value = Current.AddDays(1);
                            }

                            prospectiveNextDate = _viewModel.GetStartDate(value);
                        }
                        break;

                    case RepeatOptions.Monthly:
                        prospectiveNextDate = _startDate.AddMonths((int)_repeatInterval * _countSoFar).Date;
                        break;

                    default:
                        throw new NotImplementedException("Unknown repeat option");
                    }
                }

                // If limiting by end date, check that
                if (_viewModel.IsEndDateChecked)
                {
                    if (prospectiveNextDate > _viewModel.EndDate)
                    {
                        return(false);
                    }
                }

                // Otherwise we're good! Continue!
                _countSoFar++;
                Current = prospectiveNextDate;
                return(true);
            }