protected override void OnInitialized() { var configs = ServiceProvider.GetServices <DateRangePickerConfig>(); var config = configs?.FirstOrDefault(); if (!string.IsNullOrEmpty(Config) && configs.Any(c => c.Name == Config)) { config = configs.First(c => c.Name == Config); } if (config == null) { config = new DateRangePickerConfig(); } config.CopyProperties(this); ConfigAttributes = config.Attributes; if (string.IsNullOrEmpty(DateFormat)) { DateFormat = Culture.DateTimeFormat.ShortDatePattern; } if (!TimePicker24Hour.HasValue) { TimePicker24Hour = Culture.DateTimeFormat.LongTimePattern.EndsWith("tt"); } StartTime = TStartDate.HasValue ? TStartDate.Value.TimeOfDay : InitialStartTime ?? TimeSpan.Zero; EndTime = TEndDate.HasValue ? TEndDate.Value.TimeOfDay : InitialEndTime ?? TimeSpan.FromDays(1).Add(TimeSpan.FromTicks(-1)); if (SingleDatePicker == true && TimePicker == false && !AutoApply.HasValue) { AutoApply = true; } if (!FirstDayOfWeek.HasValue) { FirstDayOfWeek = Culture.DateTimeFormat.FirstDayOfWeek; } if (Inline == true) { Prerender = true; } Render = Prerender == true; LeftCalendar = new CalendarType(this, SideType.Left); RightCalendar = new CalendarType(this, SideType.Right); TStartDate = StartDate?.Date.Add(StartTime); TEndDate = EndDate?.Date.Add(EndTime); }
protected override void OnInitialized() { var configs = ServiceProvider.GetServices <DateRangePickerConfig>(); var config = configs?.FirstOrDefault(); if (!string.IsNullOrEmpty(Config) && configs.Any(c => c.Name == Config)) { config = configs.First(c => c.Name == Config); } if (config == null) { config = new DateRangePickerConfig(); } config.CopyProperties(this); ConfigAttributes = config.Attributes; if (string.IsNullOrEmpty(DateFormat)) { DateFormat = Culture.DateTimeFormat.ShortDatePattern; } if (SingleDatePicker == true) { AutoApply = true; } if (!FirstDayOfWeek.HasValue) { FirstDayOfWeek = Culture.DateTimeFormat.FirstDayOfWeek; } LeftCalendar = new CalendarType(FirstDayOfWeek.Value); RightCalendar = new CalendarType(FirstDayOfWeek.Value); StartDate = StartDate?.Date; EndDate = EndDate?.Date.AddDays(1).AddTicks(-1); AdjustCalendars(); base.OnInitialized(); }