/// <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; }
/// <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(); } return(combinedDates); }
/// <summary> /// GetDates gets the resolved Dates /// </summary> /// <returns>The resolved Dates</returns> private Dates GetDates() { Dates dates = null; if (this.datesNoParents != null) { dates = (Dates)this.datesNoParents.Clone(); } Culture[] parentCultures = this.GetParents(); foreach (Culture parentCulture in parentCultures) { dates = Dates.Combine(dates, parentCulture.datesNoParents); } return(dates); }
/// <summary> /// Initializes a new instance of the Culture class /// </summary> /// <param name="cultureData">The CultureData for this language/script/region/variant</param> public Culture(CultureData cultureData) { this.casingNoParents = cultureData.Casing; this.charactersNoParents = cultureData.Characters; this.datesNoParents = cultureData.Dates; this.delimitersNoParents = cultureData.Delimiters; this.Identity = cultureData.Identity; this.languageDisplayNamesNoParents = cultureData.LanguageDisplayNames; this.layoutNoParents = cultureData.Layout; this.listPatternsNoParents = cultureData.ListPatterns; this.messagesNoParents = cultureData.Messages; this.numbersNoParents = cultureData.Numbers; this.regionDisplayNamesNoParents = cultureData.RegionDisplayNames; this.ruleBasedNumberFormattingNoParents = cultureData.RuleBasedNumberFormatting; this.scriptDisplayNamesNoParents = cultureData.ScriptDisplayNames; this.unitPatternSetsNoParents = cultureData.UnitPatternSets; }