/// <summary> /// Replaces the schedule current stored against the given ID with a new one. /// </summary> /// <param name="scheduleToReplace">The ID of the schedule that should be replaced.</param> /// <param name="newSchedule">The new schedule.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="scheduleToReplace"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="newSchedule"/> is <see langword="null" />. /// </exception> /// <exception cref="UnknownScheduleException"> /// Thrown if <paramref name="scheduleToReplace"/> is not linked to a known schedule. /// </exception> public void Update( ScheduleId scheduleToReplace, ISchedule newSchedule) { { Lokad.Enforce.Argument(() => scheduleToReplace); Lokad.Enforce.Argument(() => newSchedule); Lokad.Enforce.With<UnknownScheduleException>( m_Schedules.ContainsKey(scheduleToReplace), Resources.Exceptions_Messages_UnknownSchedule); } var oldInfo = m_Schedules[scheduleToReplace].Information; var info = new ScheduleInformation( scheduleToReplace, oldInfo.Name, oldInfo.Description); m_Schedules[scheduleToReplace] = new ScheduleMap(info, newSchedule); }
/// <summary> /// Initializes a new instance of the <see cref="ScheduleMap"/> class. /// </summary> /// <param name="information">The information describing the schedule.</param> /// <param name="schedule">The schedule.</param> public ScheduleMap(ScheduleInformation information, ISchedule schedule) { { Debug.Assert(information != null, "The schedule information should not be a null reference."); Debug.Assert(schedule != null, "The schedule should not be a null reference."); } m_Info = information; m_Schedule = schedule; }
/// <summary> /// Adds the <see cref="ISchedule"/> object with the variables it affects and the dependencies for that schedule. /// </summary> /// <param name="schedule">The schedule that should be stored.</param> /// <param name="name">The name of the schedule that is being described by this information object.</param> /// <param name="description">The description of the schedule that is being described by this information object.</param> /// <returns>An object identifying and describing the schedule.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="schedule"/> is <see langword="null" />. /// </exception> public ScheduleInformation Add( ISchedule schedule, string name, string description) { { Lokad.Enforce.Argument(() => schedule); } var id = new ScheduleId(); var info = new ScheduleInformation(id, name, description); m_Schedules.Add(id, new ScheduleMap(info, schedule)); return info; }