Example #1
0
        public List <StartingLaneFlat> GetLeaves(List <StartingLane> rootLanes, string parentStartingLane)
        {
            var parentPath = FindParent(new Stack <StartingLane>(), rootLanes, parentStartingLane);

            if (parentPath == null)
            {
                return(new List <StartingLaneFlat>());
            }
            var leaves = new List <StartingLaneFlat>();

            if (parentPath.Count == 0)
            {
                BuildLeaves(leaves, new Stack <StartingLane>(), rootLanes);
            }
            else
            {
                var parent = parentPath.Pop();
                if (parent.SubLanes == null || parent.SubLanes.Count == 0)
                {
                    StartingLaneFlat flat = new StartingLaneFlat();
                    flat.StartingLaneId = parent.StartingLaneId;
                    flat.ShortName      = parent.ShortName;
                    flat.FullName       = "";
                    leaves.Add(flat);
                }
                else
                {
                    BuildLeaves(leaves, new Stack <StartingLane>(), parent.SubLanes);
                }
            }
            return(leaves);
        }
Example #2
0
        private StartingLaneFlat GetFlattened(Stack <StartingLane> path)
        {
            if (path == null)
            {
                return(null);
            }

            StartingLane  leaf     = null;
            StringBuilder fullName = null;

            foreach (var current in path)
            {
                if (leaf == null)
                {
                    leaf     = current;
                    fullName = new StringBuilder(current.ShortName);
                }
                else
                {
                    fullName.Insert(0, " ");
                    fullName.Insert(0, current.ShortName);
                }
            }

            if (leaf == null)
            {
                return(null);
            }

            var flat = new StartingLaneFlat();

            flat.StartingLaneId = leaf.StartingLaneId;
            flat.ShortName      = leaf.ShortName;
            flat.FullName       = fullName.ToString();
            return(flat);
        }