public static GetCalendarPreferenceIds ( string regionId ) : string[] | ||
regionId | string | The Id of the region to get the calendar preference ids for |
return | string[] |
/// <summary> /// GetAvailableCalendars gets an array of .NET calendars available to the Culture /// </summary> /// <param name="culture">The Culture to get the Calendars for</param> /// <returns>An array of .NET calendars available to the Culture</returns> /// <remarks>The list is filtered to include only those .NET Calendars that can be used /// with custom cultures</remarks> private static System.Globalization.Calendar[] GetAvailableCalendars(Culture culture) { if (culture.Dates == null || culture.Dates.Calendars == null) { return(null); } List <System.Globalization.Calendar> availableCalendars = new List <System.Globalization.Calendar>(); Types.Calendar[] allCalendars = null; if (culture.Identity.Region != null) { string[] calendarPreferenceIds = RegionExtensions.GetCalendarPreferenceIds(culture.Identity.Region.Id); if (calendarPreferenceIds != null) { allCalendars = (from cpi in calendarPreferenceIds select(from c in culture.Dates.Calendars where c.Id == cpi select c).FirstOrDefault()).ToArray(); } } if (allCalendars == null) { allCalendars = culture.Dates.Calendars; } foreach (Types.Calendar calendar in allCalendars) { System.Globalization.Calendar dotNetCalendar = GetCalendar(calendar); // The CultureAndRegionInfoBuilder.AvailableCalendars property does not allow // certain types of calendars to be included in the array assigned to it if (dotNetCalendar != null && dotNetCalendar.GetType() != typeof(PersianCalendar) && dotNetCalendar.GetType() != typeof(TaiwanLunisolarCalendar) && dotNetCalendar.GetType() != typeof(KoreanLunisolarCalendar) && dotNetCalendar.GetType() != typeof(JapaneseLunisolarCalendar) && dotNetCalendar.GetType() != typeof(ChineseLunisolarCalendar) && dotNetCalendar.GetType() != typeof(JulianCalendar)) { availableCalendars.Add(dotNetCalendar); } } return(availableCalendars.ToArray()); }
/// <summary> /// GetCalendarPreferences gets the calendar preference ids for the RegionInfo /// </summary> /// <param name="regionInfo">The RegionInfo to get the calendar preference ids for</param> /// <returns>The calendar preference ids for the RegionInfo</returns> public static string[] GetCalendarPreferenceIds(this RegionInfo regionInfo) { return(RegionExtensions.GetCalendarPreferenceIds(regionInfo.TwoLetterISORegionName)); }