Clone() public method

Clone clones the object
public Clone ( ) : object
return object
Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
Archivo: Dates.cs Proyecto: 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);
        }