/// <summary> /// Applies the specified <see cref="DateSpecification"/> to the reference date. /// </summary> /// <param name="date">The reference date.</param> /// <param name="handler">The <see cref="DateSpecification"/>.</param> /// <seealso cref="DateSpecification.ApplyTo(DateTime)"/> /// <returns>The resulting DateTime after applying the specification.</returns> public static DateTime Apply(this DateTime date, Action <DateSpecification> handler) { var instance = new DateSpecification(); handler.Invoke(instance); return(Apply(date, instance)); }
public static DateSpecification GetDateFromJson(string dtJson) { try { var dateModel = JsonConvert.DeserializeObject <DateJsonModel>(dtJson); var dateSpec = new DateSpecification(); dateSpec.IsRange = dateModel.isRange; if (!dateSpec.IsRange) { FillDate(dateSpec.Date, dateModel.dateType, dateModel.date); } else { FillDate(dateSpec.DateRange.StartDate, dateModel.dateType, dateModel.date); FillDate(dateSpec.DateRange.EndDate, dateModel.dateType, dateModel.endDate); } return(dateSpec); } catch (Exception) { return(null); } }
public static void SetDateFromString(DateSpecification dateSpec, string dateStr) { // TODO }
public static string GetStringForDates(DateSpecification dateSpec) { // TODO return(string.Empty); }
/// <summary> /// Applies the specified <see cref="DateSpecification"/> to the reference date. /// </summary> /// <param name="date">The reference date.</param> /// <param name="handler">The <see cref="DateSpecification"/>.</param> /// <seealso cref="DateSpecification.ApplyTo(DateTime)"/> /// <returns>The resulting DateTime after applying the specification.</returns> public static DateTime Apply(this DateTime date, DateSpecification handler) { return(handler.ApplyTo(date)); }