예제 #1
0
파일: Dates.cs 프로젝트: pifta/NCLDR
        /// <summary>
        /// Combine combines a child with a parent as necessary and returns the combined object
        /// </summary>
        /// <param name="combinedDates">The child object</param>
        /// <param name="parentDates">The parent object</param>
        /// <returns>The combined object</returns>
        public static Dates Combine(Dates combinedDates, Dates parentDates)
        {
            if (combinedDates == null && parentDates == null)
            {
                return(null);
            }
            else if (combinedDates == null)
            {
                return((Dates)parentDates.Clone());
            }
            else if (parentDates == null)
            {
                return(combinedDates);
            }

            if (combinedDates.DefaultCalendarId == null)
            {
                combinedDates.DefaultCalendarId = parentDates.DefaultCalendarId;
            }

            if (combinedDates.Calendars == null)
            {
                combinedDates.Calendars = parentDates.Calendars;
            }
            else if (combinedDates.Calendars != null && parentDates.Calendars != null)
            {
                // combine the list calendars
                List <Calendar> combinedCalendars = combinedDates.Calendars.ToList();
                foreach (Calendar parentCalendar in parentDates.Calendars)
                {
                    Calendar combinedCalendar = (from c in combinedCalendars
                                                 where string.Compare(c.Id, parentCalendar.Id, StringComparison.InvariantCulture) == 0
                                                 select c).FirstOrDefault();
                    if (combinedCalendar == null)
                    {
                        combinedCalendars.Add(parentCalendar);
                    }
                    else
                    {
                        combinedCalendar = Calendar.Combine(combinedCalendar, parentCalendar);
                    }
                }

                combinedDates.Calendars = combinedCalendars.ToArray();
            }

            if (combinedDates.DisplayNames == null)
            {
                combinedDates.DisplayNames = parentDates.DisplayNames;
            }
            else if (parentDates.DisplayNames != null)
            {
                combinedDates.DisplayNames = DatesDisplayNames.Combine(combinedDates.DisplayNames, parentDates.DisplayNames);
            }

            return(combinedDates);
        }
예제 #2
0
        /// <summary>
        /// Combine combines a child with a parent as necessary and returns the combined object
        /// </summary>
        /// <param name="combinedDatesDisplayNames">The child object</param>
        /// <param name="parentDatesDisplayNames">The parent object</param>
        /// <returns>The combined object</returns>
        public static DatesDisplayNames Combine(DatesDisplayNames combinedDatesDisplayNames, DatesDisplayNames parentDatesDisplayNames)
        {
            if (combinedDatesDisplayNames.Era == null)
            {
                combinedDatesDisplayNames.Era = parentDatesDisplayNames.Era;
            }

            if (combinedDatesDisplayNames.Year == null)
            {
                combinedDatesDisplayNames.Year = parentDatesDisplayNames.Year;
            }

            if (combinedDatesDisplayNames.Month == null)
            {
                combinedDatesDisplayNames.Month = parentDatesDisplayNames.Month;
            }

            if (combinedDatesDisplayNames.Day == null)
            {
                combinedDatesDisplayNames.Day = parentDatesDisplayNames.Day;
            }

            if (combinedDatesDisplayNames.Yesterday == null)
            {
                combinedDatesDisplayNames.Yesterday = parentDatesDisplayNames.Yesterday;
            }

            if (combinedDatesDisplayNames.Today == null)
            {
                combinedDatesDisplayNames.Today = parentDatesDisplayNames.Today;
            }

            if (combinedDatesDisplayNames.Tomorrow == null)
            {
                combinedDatesDisplayNames.Tomorrow = parentDatesDisplayNames.Tomorrow;
            }

            if (combinedDatesDisplayNames.Week == null)
            {
                combinedDatesDisplayNames.Week = parentDatesDisplayNames.Week;
            }

            if (combinedDatesDisplayNames.WeekDay == null)
            {
                combinedDatesDisplayNames.WeekDay = parentDatesDisplayNames.WeekDay;
            }

            if (combinedDatesDisplayNames.Hour == null)
            {
                combinedDatesDisplayNames.Hour = parentDatesDisplayNames.Hour;
            }

            if (combinedDatesDisplayNames.Minute == null)
            {
                combinedDatesDisplayNames.Minute = parentDatesDisplayNames.Minute;
            }

            if (combinedDatesDisplayNames.Second == null)
            {
                combinedDatesDisplayNames.Second = parentDatesDisplayNames.Second;
            }

            if (combinedDatesDisplayNames.Zone == null)
            {
                combinedDatesDisplayNames.Zone = parentDatesDisplayNames.Zone;
            }

            return combinedDatesDisplayNames;
        }
예제 #3
0
        /// <summary>
        /// Combine combines a child with a parent as necessary and returns the combined object
        /// </summary>
        /// <param name="combinedDatesDisplayNames">The child object</param>
        /// <param name="parentDatesDisplayNames">The parent object</param>
        /// <returns>The combined object</returns>
        public static DatesDisplayNames Combine(DatesDisplayNames combinedDatesDisplayNames, DatesDisplayNames parentDatesDisplayNames)
        {
            if (combinedDatesDisplayNames.Era == null)
            {
                combinedDatesDisplayNames.Era = parentDatesDisplayNames.Era;
            }

            if (combinedDatesDisplayNames.Year == null)
            {
                combinedDatesDisplayNames.Year = parentDatesDisplayNames.Year;
            }

            if (combinedDatesDisplayNames.Month == null)
            {
                combinedDatesDisplayNames.Month = parentDatesDisplayNames.Month;
            }

            if (combinedDatesDisplayNames.Day == null)
            {
                combinedDatesDisplayNames.Day = parentDatesDisplayNames.Day;
            }

            if (combinedDatesDisplayNames.Yesterday == null)
            {
                combinedDatesDisplayNames.Yesterday = parentDatesDisplayNames.Yesterday;
            }

            if (combinedDatesDisplayNames.Today == null)
            {
                combinedDatesDisplayNames.Today = parentDatesDisplayNames.Today;
            }

            if (combinedDatesDisplayNames.Tomorrow == null)
            {
                combinedDatesDisplayNames.Tomorrow = parentDatesDisplayNames.Tomorrow;
            }

            if (combinedDatesDisplayNames.Week == null)
            {
                combinedDatesDisplayNames.Week = parentDatesDisplayNames.Week;
            }

            if (combinedDatesDisplayNames.WeekDay == null)
            {
                combinedDatesDisplayNames.WeekDay = parentDatesDisplayNames.WeekDay;
            }

            if (combinedDatesDisplayNames.Hour == null)
            {
                combinedDatesDisplayNames.Hour = parentDatesDisplayNames.Hour;
            }

            if (combinedDatesDisplayNames.Minute == null)
            {
                combinedDatesDisplayNames.Minute = parentDatesDisplayNames.Minute;
            }

            if (combinedDatesDisplayNames.Second == null)
            {
                combinedDatesDisplayNames.Second = parentDatesDisplayNames.Second;
            }

            if (combinedDatesDisplayNames.Zone == null)
            {
                combinedDatesDisplayNames.Zone = parentDatesDisplayNames.Zone;
            }

            return(combinedDatesDisplayNames);
        }