Exemple #1
0
        public IEnumerable <string> FilesByLine(FolderName folder, Func <FindResult, string> mapFunc, int indentLevel = 0)
        {
            var lineMatched = false;

            foreach (var file in folder.Files.Where(MatchedFile))
            {
                foreach (var result in FileLines(file))
                {
                    if (!lineMatched)
                    {
                        FolderMatched?.Invoke(this, new FolderArgs(folder));
                    }

                    var clone = result.Clone();
                    clone.File        = file;
                    clone.IndentLevel = indentLevel;

                    yield return(mapFunc(clone));
                }

                FileMatched?.Invoke(this, new FileArgs(file));
            }

            foreach (var subfolder in folder.Folders)
            {
                foreach (var result in FilesByLine(subfolder, mapFunc, indentLevel + 1))
                {
                    yield return(result);
                }
            }
        }
        internal void OnFileMatched(SVR_VideoLocal_Place vlp)
        {
            var series = vlp.VideoLocal?.GetAnimeEpisodes().Select(a => a.GetAnimeSeries()).DistinctBy(a => a.AniDB_ID).ToList() ?? new List <SVR_AnimeSeries>();

            FileMatched?.Invoke(
                null, new FileMatchedEventArgs
            {
                FileInfo    = vlp,
                AnimeInfo   = series.Select(a => a.GetAnime()).Cast <IAnime>().ToList(),
                EpisodeInfo = vlp.VideoLocal?.GetAnimeEpisodes().Cast <IEpisode>().ToList(),
                GroupInfo   = series.Select(a => a.AnimeGroup).DistinctBy(a => a.AnimeGroupID).Cast <IGroup>().ToList(),
            }
                );
        }
Exemple #3
0
        public IEnumerable <FindResult> MatchedFiles(FolderName sourceFolder, int indentLevel = 0)
        {
            var _folder = none <FolderName>();

            foreach (var file in sourceFolder.Files.Where(MatchedFile))
            {
                if (_folder.If(out var folder))
                {
                    if (folder == file.Folder)
                    {
                        yield return(new FindResult {
                            FileNameExtension = file.NameExtension, IndentLevel = indentLevel
                        });
                    }
                    else
                    {
                        _folder = file.Folder.Some();
                        yield return(new FindResult {
                            Folder = _folder, FileNameExtension = file.NameExtension, IndentLevel = indentLevel
                        });

                        FolderMatched?.Invoke(this, new FolderArgs(file.Folder));
                    }
                }

                FileMatched?.Invoke(this, new FileArgs(file));
            }

            foreach (var subfolder in sourceFolder.Folders)
            {
                foreach (var result in MatchedFiles(subfolder, indentLevel + 1))
                {
                    yield return(result);
                }
            }
        }