当前位置: 首页>>代码示例>>C#>>正文


C# ISchedule.TraverseAllScheduleVertices方法代码示例

本文整理汇总了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;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:37,代码来源:ScheduleVerifier.cs

示例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;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:39,代码来源:ScheduleVerifier.cs

示例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;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:35,代码来源:ScheduleVerifier.cs

示例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;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:28,代码来源:ScheduleVerifier.cs

示例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);
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:38,代码来源:FixedScheduleBuilder.cs

示例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);
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:30,代码来源:ScheduleDistributorTest.cs


注:本文中的ISchedule.TraverseAllScheduleVertices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。