示例#1
0
        /// <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));
        }
示例#2
0
        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);
            }
        }
示例#3
0
 public static void SetDateFromString(DateSpecification dateSpec, string dateStr)
 {
     // TODO
 }
示例#4
0
        public static string GetStringForDates(DateSpecification dateSpec)
        {
            // TODO

            return(string.Empty);
        }
示例#5
0
 /// <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));
 }