/// <summary> /// Fetches a calendar system by its unique identifier. This provides full round-tripping of a calendar /// system. This method will always return the same reference for the same ID. /// </summary> /// <param name="id">The ID of the calendar system. This is case-sensitive.</param> /// <returns>The calendar system with the given ID.</returns> /// <seealso cref="Id"/> /// <exception cref="KeyNotFoundException">No calendar system for the specified ID can be found.</exception> /// <exception cref="NotSupportedException">The calendar system with the specified ID is known, but not supported on this platform.</exception> public static CalendarSystem ForId(string id) { Preconditions.CheckNotNull(id, nameof(id)); if (!IdToFactoryMap.TryGetValue(id, out Func <CalendarSystem> factory)) { throw new KeyNotFoundException($"No calendar system for ID {id} exists"); } return(factory()); }
/// <summary> /// Fetches a calendar system by its unique identifier. This provides full round-tripping of a calendar /// system. It is not guaranteed that calling this method twice with the same identifier will return /// identical references, but the references objects will be equal. /// </summary> /// <param name="id">The ID of the calendar system. This is case-sensitive.</param> /// <returns>The calendar system with the given ID.</returns> /// <seealso cref="Id"/> /// <exception cref="KeyNotFoundException">No calendar system for the specified ID can be found.</exception> public static CalendarSystem ForId(string id) { Func <CalendarSystem> factory; if (!IdToFactoryMap.TryGetValue(id, out factory)) { throw new KeyNotFoundException(string.Format("No calendar system for ID {0} exists", id)); } return(factory()); }