Пример #1
0
        public bool IsFiltered(Func <TFilter, bool> predicate)
        {
            if ((!IncludeFilters.Any() || IncludeFilters.Any(predicate)) && !ExcludeFilters.Any(predicate))
            {
                return(false);
            }

            ++Count;
            return(true);
        }
Пример #2
0
        public IEnumerator <Type> GetEnumerator()
        {
            IEnumerable <Type> filteredTypes = Assemblies.SelectMany(assembly => assembly.GetExportedTypes());

            if (IncludeFilters.Any())
            {
                filteredTypes = filteredTypes.Where(type => IncludeFilters.Any(filter => filter(type)));
            }

            return(filteredTypes.Where(type => !ExcludeFilters.Any(filter => filter(type))).GetEnumerator());
        }
        /// <summary>
        /// Applies the filters to the a given source list
        /// </summary>
        /// <param name="sourceList">The source list</param>
        public IList <TItem> ApplyFilters(IList <TItem> sourceList)
        {
            IList <TItem> result = IncludeFilters.Any()
                ? sourceList.Where(a => IncludeFilters.All(f => f.Invoke(a)))
                                   .Except(sourceList.Where(a => ExcludeFilters.Any(f => f.Invoke(a))))
                                   .ToList()
                : new List <TItem>();

            return(result
                   .Concat(IncludedItems)
                   .Except(ExcludedItems)
                   .ToList());
        }
Пример #4
0
 public List <string> GetGenres()
 {
     return(IncludeFilters.Where(f => f.Type.ToLower() == "genre").Select(f => f.Keyword).ToList());
 }
        private bool ShouldBrowseDirectory(IDirectoryInfo directory)
        {
            var result = true;

            if (!directory.Exists)
            {
                _log.DebugFormat("Skipping scanning directory {0}.", directory.FullName);
                result = false;
            }
            else if (directory.Parent == null)
            {
// ReSharper disable RedundantAssignment
                result = true;
// ReSharper restore RedundantAssignment
            }
            else if (_defautExclussions.Contains(directory.Name) &&
                     (directory.Attributes & FileAttributes.System) == FileAttributes.System)
            {
                _log.DebugFormat("Skipping scanning directory {0} because it is directory that is a part of default exclusion.", directory.FullName);
                result = false;
            }
            else if ((directory.Attributes & FileAttributes.Offline) == FileAttributes.Offline ||
                     (directory.Attributes & FileAttributes.Device) == FileAttributes.Device)
            {
                _log.DebugFormat("Skipping scanning directory {0} because it is a Offline or a Device.", directory.FullName);
                result = false;
            }
            else if (!ScanSystem && (directory.Attributes & FileAttributes.System) == FileAttributes.System)
            {
                _log.DebugFormat("Skipping scanning directory {0} because it is a System directory.", directory.FullName);
                result = false;
            }
            else if (!ScanHidden && (directory.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
            {
                _log.DebugFormat("Skipping scanning directory {0} because it is a Hidden directory.", directory.FullName);
                result = false;
            }

            if (IncludeFilters.Count > 0 && !FindFilesRegEx.MatchesFilePattern(directory.FullName, IncludeFilters.ToArray()))
            {
                return(false);
            }

            if (ExcludeFilters.Count > 0 && FindFilesRegEx.MatchesFilePattern(directory.FullName, ExcludeFilters.ToArray()))
            {
                return(false);
            }
            return(result);
        }
        private bool ShouldAddFile(IFileSystemInfo fileInfo)
        {
            var result = true;

            if (!ScanHidden && (fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
            {
                _log.DebugFormat("Skipping scanning file {0}.", fileInfo.FullName);
                result = false;
            }
            else if (!ScanSystem && (fileInfo.Attributes & FileAttributes.System) == FileAttributes.System)
            {
                _log.DebugFormat("Skipping scanning file {0}.", fileInfo.FullName);
                result = false;
            }
            else if (IncludeFilters.Count > 0 && !FindFilesRegEx.MatchesFilePattern(fileInfo.FullName, IncludeFilters.ToArray()))
            {
                return(false);
            }
            else if (ExcludeFilters.Count > 0 && FindFilesRegEx.MatchesFilePattern(fileInfo.FullName, ExcludeFilters.ToArray()))
            {
                return(false);
            }
            return(result);
        }