Beispiel #1
0
        private List <IRepoFileContainerDescriptor> EnumerateMonths(
            IRepoFileContainerDescriptor yearDir)
        {
            Check.DoAssertLambda(yearDir.Level == FolderLevelYear, () => new ArgumentException("Year level expected in yearDir"));

            List <IRepoFileContainerDescriptor> retval = new List <IRepoFileContainerDescriptor>();

            string root = Path.Combine(this.RootPath, yearDir.RelativePath);

            if (_directoryProvider.Exists(root))
            {
                IEnumerable <string> monthDirs = _directoryProvider.EnumerateDirectories(
                    root
                    , _dirLevelTraits[FolderLevelMonth].DirNameMask);
                foreach (string monthDir in monthDirs)
                {
                    int month = 0;
                    if (_dirLevelTraits[FolderLevelMonth].IsValidDir(_directoryProvider.GetLastPathComponent(monthDir), ref month))
                    {
                        IRepoFileContainerDescriptor descrMonth =
                            _dirLevelTraits[FolderLevelMonth].GetFolderDescriptorByRange(
                                yearDir.Start.AddMonths(month - 1));

                        retval.Add(descrMonth);
                    }
                }         // foreach (string monthDir in monthDirs)
            }             // if (Directory.Exists(this.RootPath))
            return(retval);
        }
Beispiel #2
0
        internal List <IRepoFileContainerDescriptor> Enumerate(
            IDirectoryProvider dirProvider, string rootPath, IRepoFileContainerDescriptor parent)
        {
            IEnumerable <string> allDirPaths           = dirProvider.EnumerateDirectories(rootPath, DirNameMask);
            List <IRepoFileContainerDescriptor> retval = new List <IRepoFileContainerDescriptor>();

            foreach (string name in allDirPaths.Select((p) => dirProvider.GetLastPathComponent(p)))
            {
                IRepoFileContainerDescriptor descr = GetFolderDescriptor(parent, name);
                if (null != descr)
                {
                    retval.Add(descr);
                }
            }

            return(retval);
        }