Beispiel #1
0
        public bool HaveCycles()
        {
            HashSet <FolderAsset> visitedFolders = new HashSet <FolderAsset>();
            Queue <FolderAsset>   foldersToVisit = new Queue <FolderAsset>();

            foldersToVisit.Enqueue(this);
            visitedFolders.Add(this);

            while (foldersToVisit.Count > 0)
            {
                FolderAsset current = foldersToVisit.Dequeue();

                foreach (FolderAsset folderAsset in current.AssetsList.OfType <FolderAsset>())
                {
                    if (folderAsset == null)
                    {
                        continue;
                    }
                    if (visitedFolders.Contains(folderAsset))
                    {
                        return(true);
                    }
                    visitedFolders.Add(folderAsset);
                    foldersToVisit.Enqueue(folderAsset);
                }
            }

            return(false);
        }
 public void SetParentFolder(FolderAsset folderAsset)
 {
     m_ParentFolder = folderAsset;
 }