コード例 #1
0
        /// <summary>
        /// Initialize the Holiday calendar data provider and calendar code.
        /// </summary>
        /// <param name="calendarCode">"U.S.-NewYork"</param>
        /// <param name="provider">The underlying holiday dates provider.</param>
        /// <param name="startYear">Used for initialization. Loads holidays from the starting year.</param>
        /// <param name="endYear">Used for initialization. Loads holidays up to the ending year.</param>
        public virtual void Init(string calendarCode, ICalendarDataProvider provider, int startYear, int endYear)
        {
            _calendarCode        = calendarCode;
            _holidayDataProvider = provider;
            _holidayDataProvider.CalendarCode = _calendarCode;
            List <KeyValuePair <int, List <DateTime> > > holidays = _holidayDataProvider.Holidays(startYear, endYear);

            // Now sort the holidays into ascending order.
            foreach (KeyValuePair <int, List <DateTime> > pair in holidays)
            {
                _holidayListMap[pair.Key] = pair.Value;
                Dictionary <string, DateTime> holidaysByYearMap = new Dictionary <string, DateTime>();

                // Now store each date into map.
                foreach (DateTime date in pair.Value)
                {
                    string format = GetDateFormat(date);
                    _holidayMap[format]       = date;
                    holidaysByYearMap[format] = date;
                }
                _yearHolidayMap[pair.Key] = holidaysByYearMap;
            }

            // Notify.
            if (OnCalendarChanged != null)
            {
                OnCalendarChanged(this, new EventArgs());
            }
        }
コード例 #2
0
        public CalendarCancelOperation(ICalendarDataProvider dataProvider)
        {
            if (dataProvider == null)
            {
                throw new ArgumentNullException(nameof(dataProvider));
            }

            this.DataProvider = dataProvider;
        }
コード例 #3
0
ファイル: Calendar.cs プロジェクト: vokenet/CommonLibrary.NET
 /// <summary>
 /// Initialize the Holiday calendar data provider and calendar code.
 /// </summary>
 /// <param name="calendarCode">"country='US', province='NewYork', ref='some value to indicate source'"</param>
 /// <param name="provider">The underlying holiday dates provider.</param>
 /// <param name="startYear">Used for initialization. Loads holidays from the starting year.</param>
 /// <param name="endYear">Used for initialization. Loads holidays up to the ending year.</param>
 public static void Init(string calendarCode, ICalendarDataProvider provider, int startYear, int endYear)
 {
     _provider.Init(calendarCode, provider, startYear, endYear);
 }
コード例 #4
0
        public CalendarViewModel(IModalDialog modalDialog, Func <Task <CancelReason> > cancelReasonSelector, INavigationService navigationService, ICalendarDataProvider dataProvider, Func <string, string, string> localizationManager, DataCache dataCache)
        {
            if (modalDialog == null)
            {
                throw new ArgumentNullException(nameof(modalDialog));
            }
            if (cancelReasonSelector == null)
            {
                throw new ArgumentNullException(nameof(cancelReasonSelector));
            }


            this.ModalDialog          = modalDialog;
            this.CancelReasonSelector = cancelReasonSelector;
            this.NavigationService    = navigationService;
            this.DataProvider         = dataProvider;
            this.LocalizationManager  = localizationManager;
            this.DataCache            = dataCache;
            this.CloseDaysCommand     = new ActionCommand(this.CloseSelectedDays);
            this.CancelDaysCommand    = new ActionCommand(this.CancelSelectedDays);
            this.CurrentMonth         = DateTime.Today;
            this.NextDayCommand       = new ActionCommand(() =>
            {
                this.Load(this.CurrentMonth.AddMonths(1));
            });
            this.PreviousDayCommand = new ActionCommand(() =>
            {
                this.Load(this.CurrentMonth.AddMonths(-1));
            });
        }
コード例 #5
0
 /// <summary>
 /// Initialize using calendar code and holiday dates provider.
 /// This defaults the # of years of holidays that can be handled to +- 50;
 /// <param name="calendarCode">"U.S.-NewYork"</param>
 /// <param name="provider">The underlying holiday dates provider.</param>
 /// <param name="forwardBackRange">The number of years before and after current year
 /// for which to calculate dates.</param>
 /// </summary>
 public CalendarService(string calendarCode, ICalendarDataProvider provider, int forwardBackRange)
 {
     Init(calendarCode, provider, DateTime.Today.Year - forwardBackRange, DateTime.Today.Year + forwardBackRange);
 }
コード例 #6
0
ファイル: CalendarBuilder.cs プロジェクト: Ceodore/calendar
 public CalendarBuilder(ICalendarDataProvider calendarDataProvider)
 {
     _calendarDataProvider = calendarDataProvider;
 }