本文整理汇总了C#中ISchedule.TraverseAllScheduleVertices方法的典型用法代码示例。如果您正苦于以下问题:C# ISchedule.TraverseAllScheduleVertices方法的具体用法?C# ISchedule.TraverseAllScheduleVertices怎么用?C# ISchedule.TraverseAllScheduleVertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISchedule
的用法示例。
在下文中一共展示了ISchedule.TraverseAllScheduleVertices方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifySubSchedulesDoNotLinkBackToParentSchedule
private bool VerifySubSchedulesDoNotLinkBackToParentSchedule(
ScheduleId id,
ISchedule schedule,
Action<ScheduleIntegrityFailureType, IScheduleVertex> onValidationFailure)
{
bool result = true;
schedule.TraverseAllScheduleVertices(
schedule.Start,
(node, edges) =>
{
var scheduleNode = node as SubScheduleVertex;
if (scheduleNode == null)
{
return true;
}
var subScheduleId = scheduleNode.ScheduleToExecute;
var isKnownSchedule = m_Schedules.Contains(subScheduleId);
if (!isKnownSchedule)
{
result = false;
onValidationFailure(ScheduleIntegrityFailureType.UnknownSubSchedule, node);
return false;
}
var doesSubScheduleLink = DoesSubScheduleLinkTo(id, m_Schedules.Schedule(subScheduleId));
if (doesSubScheduleLink)
{
result = false;
onValidationFailure(ScheduleIntegrityFailureType.SubScheduleLinksBackToParentSchedule, node);
}
return true;
});
return result;
}
示例2: DoesSubScheduleLinkTo
private bool DoesSubScheduleLinkTo(ScheduleId scheduleId, ISchedule schedule)
{
var result = false;
schedule.TraverseAllScheduleVertices(
schedule.Start,
(node, edges) =>
{
var scheduleNode = node as SubScheduleVertex;
if (scheduleNode == null)
{
return true;
}
var subScheduleId = scheduleNode.ScheduleToExecute;
if (subScheduleId.Equals(scheduleId))
{
result = true;
return false;
}
var isKnownSchedule = m_Schedules.Contains(subScheduleId);
if (!isKnownSchedule)
{
result = false;
return true;
}
var doesSubScheduleLink = DoesSubScheduleLinkTo(scheduleId, m_Schedules.Schedule(subScheduleId));
if (doesSubScheduleLink)
{
result = true;
return false;
}
return true;
});
return result;
}
示例3: VerifyVerticesAreOnlyConnectedByOneEdgeInGivenDirection
private static bool VerifyVerticesAreOnlyConnectedByOneEdgeInGivenDirection(
ISchedule schedule,
Action<ScheduleIntegrityFailureType, IScheduleVertex> onValidationFailure)
{
bool result = true;
schedule.TraverseAllScheduleVertices(
schedule.Start,
(node, edges) =>
{
var outNodes = new List<IScheduleVertex>();
var outEdgeCount = 0;
foreach (var pair in edges)
{
var outNode = pair.Item2;
if (!outNodes.Contains(outNode))
{
outNodes.Add(outNode);
}
outEdgeCount++;
}
var internalResult = outEdgeCount == outNodes.Count;
result &= internalResult;
if (!internalResult)
{
onValidationFailure(ScheduleIntegrityFailureType.VertexLinksToOtherVertexInMultipleWays, node);
}
return true;
});
return result;
}
示例4: VerifyTrackForwardsFromStart
private static bool VerifyTrackForwardsFromStart(
ISchedule schedule,
Action<ScheduleIntegrityFailureType, IScheduleVertex> onValidationFailure)
{
var unvisitedNodes = new List<IScheduleVertex>(schedule.Vertices);
schedule.TraverseAllScheduleVertices(
schedule.Start,
(node, edges) =>
{
if (unvisitedNodes.Contains(node))
{
unvisitedNodes.Remove(node);
}
return true;
});
var result = unvisitedNodes.Count == 0;
if (!result)
{
foreach (var node in unvisitedNodes)
{
onValidationFailure(ScheduleIntegrityFailureType.ScheduleVertexIsNotReachableFromStart, node);
}
}
return result;
}
示例5: CopySchedule
private static Tuple<BidirectionalGraph<IScheduleVertex, ScheduleEdge>, IScheduleVertex, IScheduleVertex> CopySchedule(
ISchedule schedule)
{
var map = new Dictionary<IScheduleVertex, IScheduleVertex>();
var newSchedule = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>();
var start = CloneVertex(schedule.Start);
newSchedule.AddVertex(start);
map.Add(schedule.Start, start);
var end = CloneVertex(schedule.End);
newSchedule.AddVertex(end);
map.Add(schedule.End, end);
schedule.TraverseAllScheduleVertices(
schedule.Start,
(vertex, edges) =>
{
foreach (var pair in edges)
{
var target = pair.Item2;
if (!map.ContainsKey(target))
{
var executableVertex = CloneVertex(target);
map.Add(target, executableVertex);
newSchedule.AddVertex(executableVertex);
}
var executableSource = map[vertex];
var executableTarget = map[target];
newSchedule.AddEdge(new ScheduleEdge(executableSource, executableTarget, pair.Item1));
}
return true;
});
return new Tuple<BidirectionalGraph<IScheduleVertex, ScheduleEdge>, IScheduleVertex, IScheduleVertex>(newSchedule, start, end);
}
示例6: VerifySchedule
private static void VerifySchedule(ISchedule first, ISchedule second)
{
var linearisedEditableGraph = new List<Tuple<IScheduleVertex, List<Tuple<ScheduleElementId, IScheduleVertex>>>>();
first.TraverseAllScheduleVertices(
first.Start,
(vertex, edges) =>
{
linearisedEditableGraph.Add(
new Tuple<IScheduleVertex, List<Tuple<ScheduleElementId, IScheduleVertex>>>(
vertex,
edges.ToList()));
return true;
});
var linearisedExecutableGraph = new List<Tuple<IScheduleVertex, List<Tuple<ScheduleElementId, IScheduleVertex>>>>();
second.TraverseAllScheduleVertices(
second.Start,
(vertex, edges) =>
{
linearisedExecutableGraph.Add(
new Tuple<IScheduleVertex, List<Tuple<ScheduleElementId, IScheduleVertex>>>(
vertex,
edges.ToList()));
return true;
});
CompareLinearisedGraphs(linearisedEditableGraph, linearisedExecutableGraph);
}