Exemple #1
0
        // ----------------------------------------------------------------------

        public Folder(
            string path,
            string name,
            long size,
            long count)
        {
            Path         = path;
            Name         = name;
            Size         = size;
            Count        = count;
            CountAndSize = CountAndSize.Create(Count, Size);
        }
        // ----------------------------------------------------------------------

        static FolderInfo BuildSizeIndex(
            IDictionary <Folder, CountAndSize> folderDictionary,
            Folder folder)
        {
            if (folder == null)
            {
                return(new FolderInfo());
            }

            var depth = 0;

            var size  = folder.Size;
            var count = folder.Count;

            foreach (var childFolder in folder.Children)
            {
                var buildSizeIndex = BuildSizeIndex(
                    folderDictionary,
                    childFolder);
                depth = Math.Max(
                    depth,
                    buildSizeIndex.Depth);

                count += buildSizeIndex.Count;
                size  += buildSizeIndex.Size;
            }

            var countAndSize = CountAndSize.Create(
                count,
                size);

            folderDictionary.Add(
                folder,
                countAndSize);

            return(FolderInfo.Create(
                       depth + 1,
                       count,
                       size));
        }