Esempio n. 1
0
        public IEnumerable <DirectoryInfo> GetDirs(string filterParam = null)
        {
            OnStart(this, new EventsProgressArgs("Start Dir search"));
            FileSystemVisitorContext fscontext = new FileSystemVisitorContext();

            foreach (var dir in data.GetDirectorys(path, filterParam))
            {
                OnDirectoryFinded(this, new EventsProgressArgs("DirFinded: ")
                {
                    Dir = dir, FsContext = fscontext
                });
                if (fscontext.IsCancel)
                {
                    OnFinish(this, new EventsProgressArgs("Finish Dir search"));
                    yield break;
                }
                if (filter != null)
                {
                    OnFilterDirectoryFinded(
                        new EventsProgressArgs("FilteredDirFinded: ")
                    {
                        Dir = dir, FsContext = fscontext
                    });
                    if (fscontext.IsItemPassFilter(dir.FullName, filter))
                    {
                        if (fscontext.CheckIsItemExcluded(dir.FullName))
                        {
                            yield return(null);
                        }
                        else
                        {
                            yield return(dir);
                        }
                    }
                }
                else
                {
                    if (fscontext.CheckIsItemExcluded(dir.FullName))
                    {
                        yield return(null);
                    }
                    else
                    {
                        yield return(dir);
                    }
                }
            }
            OnFinish(this, new EventsProgressArgs("Finish Dir search"));
        }
Esempio n. 2
0
        public IEnumerable <FileInfo> GetFiles(string filterParam = null)
        {
            OnStart(this, new EventsProgressArgs("Start file search"));
            FileSystemVisitorContext fscontext = new FileSystemVisitorContext();

            foreach (var file in data.GetFiles(path, filterParam))
            {
                OnFileFinded(this, new EventsProgressArgs("FileFinded: ")
                {
                    File = file, FsContext = fscontext
                });
                if (fscontext.IsCancel)
                {
                    OnFinish(this, new EventsProgressArgs("Finish file search"));
                    yield break;
                }
                if (filter != null)
                {
                    OnFilterFileFinded(
                        new EventsProgressArgs("FilteredFileFinded: ")
                    {
                        File = file, FsContext = fscontext
                    });
                    if (fscontext.IsItemPassFilter(file.Name, filter))
                    {
                        if (fscontext.CheckIsItemExcluded(file.FullName))
                        {
                            yield return(null);
                        }
                        else
                        {
                            yield return(file);
                        }
                    }
                }
                else
                {
                    if (fscontext.CheckIsItemExcluded(file.FullName))
                    {
                        yield return(null);
                    }
                    else
                    {
                        yield return(file);
                    }
                }
            }
            OnFinish(this, new EventsProgressArgs("Finish file search"));
        }