private static Schedule CreateScheduleGraphWithOuterAndInnerLoop( ScheduleConditionInformation outerLoopConditionInfo, ScheduleConditionInformation innerLoopConditionInfo, ScheduleActionInformation outerLoopInfo, ScheduleActionInformation innerLoopInfo) { var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); graph.AddVertex(start); var end = new EndVertex(2); graph.AddVertex(end); var vertex1 = new InsertVertex(3); graph.AddVertex(vertex1); var vertex2 = new InsertVertex(4); graph.AddVertex(vertex2); var vertex3 = new ExecutingActionVertex(5, outerLoopInfo.Id); graph.AddVertex(vertex3); var vertex4 = new InsertVertex(6); graph.AddVertex(vertex4); var vertex5 = new ExecutingActionVertex(7, innerLoopInfo.Id); graph.AddVertex(vertex5); graph.AddEdge(new ScheduleEdge(start, vertex1)); graph.AddEdge(new ScheduleEdge(vertex1, vertex2)); graph.AddEdge(new ScheduleEdge(vertex2, end, outerLoopConditionInfo.Id)); graph.AddEdge(new ScheduleEdge(vertex2, vertex3)); graph.AddEdge(new ScheduleEdge(vertex3, vertex1, innerLoopConditionInfo.Id)); graph.AddEdge(new ScheduleEdge(vertex3, vertex4)); graph.AddEdge(new ScheduleEdge(vertex4, vertex5)); graph.AddEdge(new ScheduleEdge(vertex5, vertex3)); return new Schedule(graph, start, end); }
/// <summary> /// Replaces the condition current stored against the given ID with a new one. /// </summary> /// <param name="conditionToReplace">The ID of the condition that should be replaced.</param> /// <param name="newCondition">The new condition.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="conditionToReplace"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="newCondition"/> is <see langword="null" />. /// </exception> /// <exception cref="UnknownScheduleConditionException"> /// Thrown if <paramref name="conditionToReplace"/> is not linked to a known condition. /// </exception> public void Update( ScheduleElementId conditionToReplace, IScheduleCondition newCondition) { { Lokad.Enforce.Argument(() => conditionToReplace); Lokad.Enforce.Argument(() => newCondition); Lokad.Enforce.With<UnknownScheduleConditionException>( m_Conditions.ContainsKey(conditionToReplace), Resources.Exceptions_Messages_UnknownScheduleCondition); } var oldInfo = m_Conditions[conditionToReplace].Information; var info = new ScheduleConditionInformation( conditionToReplace, oldInfo.Name, oldInfo.Description); m_Conditions[conditionToReplace] = new ConditionMap(info, newCondition); }
/// <summary> /// Initializes a new instance of the <see cref="ConditionMap"/> class. /// </summary> /// <param name="information">The information describing the condition.</param> /// <param name="condition">The condition.</param> public ConditionMap(ScheduleConditionInformation information, IScheduleCondition condition) { { Debug.Assert(information != null, "The condition information should not be a null reference."); Debug.Assert(condition != null, "The condition should not be a null reference."); } m_Info = information; m_Condition = condition; }
/// <summary> /// Adds the <see cref="IScheduleCondition"/> object with the dependencies for that condition. /// </summary> /// <param name="condition">The condition that should be stored.</param> /// <param name="name">The name of the condition that is being described by this information object.</param> /// <param name="description">The description of the condition that is being described by this information object.</param> /// <returns>An object identifying and describing the condition.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="condition"/> is <see langword="null" />. /// </exception> public ScheduleConditionInformation Add( IScheduleCondition condition, string name, string description) { { Lokad.Enforce.Argument(() => condition); } var id = new ScheduleElementId(); var info = new ScheduleConditionInformation(id, name, description); m_Conditions.Add(id, new ConditionMap(info, condition)); return info; }