/// <summary>
        /// Initializes a new instance of a LocalFileSystem with the given physical root path.
        /// </summary>
        public LocalFileSystem(string root)
        {
            Guard.NotEmpty(root, nameof(root));

            _filters  = ExclusionFilters.Sensitive;
            _provider = new PhysicalFileProvider(root, _filters);
        }
Example #2
0
        /// <summary>
        /// Add a filter
        /// </summary>
        /// <param name="processAssemblyClassFilter">Filter is of the format (+ or -)&lt;processFilter&gt;[assemblyFilter]classFilter, wildcards are allowed. <br/>
        /// i.e. -[mscorlib], -[System.*]*, +[App.*]*, +[*]*
        /// </param>
        public void AddFilter(string processAssemblyClassFilter)
        {
            string     assemblyFilter;
            string     classFilter;
            string     processFilter;
            FilterType filterType;

            GetAssemblyClassName(processAssemblyClassFilter, RegExFilters, out filterType, out assemblyFilter, out classFilter, out processFilter);

            try
            {
                if (!RegExFilters)
                {
                    processFilter  = ValidateAndEscape((string.IsNullOrEmpty(processFilter) ? "*" : processFilter), "<>|\"", "process"); // Path.GetInvalidPathChars except *?
                    assemblyFilter = ValidateAndEscape(assemblyFilter, @"\[]", "assembly");
                    classFilter    = ValidateAndEscape(classFilter, @"\[]", "class/type");
                }

                var filter = new AssemblyAndClassFilter(processFilter, assemblyFilter, classFilter);
                if (filterType == FilterType.Inclusion)
                {
                    InclusionFilters.Add(filter);
                }

                if (filterType == FilterType.Exclusion)
                {
                    ExclusionFilters.Add(filter);
                }
            }
            catch (Exception)
            {
                HandleInvalidFilterFormat(processAssemblyClassFilter);
            }
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of a PhysicalFileProvider at the given root directory.
        /// </summary>
        /// <param name="root">The root directory. This should be an absolute path.</param>
        /// <param name="filters">Specifies which files or directories are excluded.</param>
        public TemplateFileProvider(string root, ExclusionFilters filters)
        {
            if (!Path.IsPathRooted(root))
            {
                throw new ArgumentException("The path must be absolute.", nameof(root));
            }

            var fullRoot = Path.GetFullPath(root);

            // When we do matches in GetFullPath, we want to only match full directory names.
            if (fullRoot.EndsWith("/"))
            {
                Root = fullRoot;
            }
            else
            {
                Root = fullRoot + "/";
            }

            if (!Directory.Exists(Root))
            {
                throw new DirectoryNotFoundException(Root);
            }

            _filters = filters;
        }
        /// <summary>
        /// Initializes an instance of <see cref="PhysicalDirectoryContents"/>
        /// </summary>
        /// <param name="directory">The directory</param>
        /// <param name="filters">Specifies which files or directories are excluded from enumeration.</param>
        public PhysicalDirectoryContents(string directory, ExclusionFilters filters)
        {
            ThrowHelper.ThrowIfNull(directory);

            _directory = directory;
            _filters   = filters;
        }
        /// <summary>
        /// Initializes an instance of <see cref="PhysicalFilesWatcher" /> that watches files in <paramref name="root" />.
        /// Wraps an instance of <see cref="System.IO.FileSystemWatcher" />
        /// </summary>
        /// <param name="root">Root directory for the watcher</param>
        /// <param name="fileSystemWatcher">The wrapped watcher that is watching <paramref name="root" /></param>
        /// <param name="pollForChanges">
        /// True when the watcher should use polling to trigger instances of
        /// <see cref="IChangeToken" /> created by <see cref="CreateFileChangeToken(string)" />
        /// </param>
        /// <param name="filters">Specifies which files or directories are excluded. Notifications of changes to are not raised to these.</param>
        public PhysicalFilesWatcher(
            string root,
            FileSystemWatcher fileSystemWatcher,
            bool pollForChanges,
            ExclusionFilters filters)
        {
            if (fileSystemWatcher == null && !pollForChanges)
            {
                throw new ArgumentNullException(nameof(fileSystemWatcher), SR.Error_FileSystemWatcherRequiredWithoutPolling);
            }

            _root = root;

            if (fileSystemWatcher != null)
            {
                _fileWatcher = fileSystemWatcher;
                _fileWatcher.IncludeSubdirectories = true;
                _fileWatcher.Created += OnChanged;
                _fileWatcher.Changed += OnChanged;
                _fileWatcher.Renamed += OnRenamed;
                _fileWatcher.Deleted += OnChanged;
                _fileWatcher.Error   += OnError;
            }

            PollForChanges = pollForChanges;
            _filters       = filters;

            PollingChangeTokens = new ConcurrentDictionary <IPollingChangeToken, IPollingChangeToken>();
            _timerFactory       = () => NonCapturingTimer.Create(RaiseChangeEvents, state: PollingChangeTokens, dueTime: TimeSpan.Zero, period: DefaultPollingInterval);
        }
Example #6
0
        /// <summary>
        /// Should we instrument this asssembly
        /// </summary>
        /// <param name="processName"></param>
        /// <returns></returns>
        public bool InstrumentProcess(string processName)
        {
            if (string.IsNullOrEmpty(processName))
            {
                return(false);
            }

            if (!ExclusionFilters.Any() && !InclusionFilters.Any())
            {
                return(true);
            }

            if (IsProcessExcluded(processName))
            {
                return(false);
            }

            if (InclusionFilters.Any())
            {
                var matchingInclusionFilters = InclusionFilters.GetMatchingFiltersForProcessName(processName);
                return(matchingInclusionFilters.Any());
            }

            return(true); // not excluded and no inclusion filters
        }
Example #7
0
        /// <summary>
        /// Add a filter
        /// </summary>
        /// <param name="assemblyClassName">A filter is of the format (+ or -)[assemblyName]className, wildcards are allowed. <br/>
        /// i.e. -[mscorlib], -[System.*]*, +[App.*]*, +[*]*
        /// </param>
        public void AddFilter(string assemblyClassName)
        {
            string     assemblyName;
            string     className;
            string     processName;
            FilterType filterType;

            GetAssemblyClassName(assemblyClassName, RegExFilters, out filterType, out assemblyName, out className, out processName);

            if (!RegExFilters)
            {
                processName  = (string.IsNullOrEmpty(processName) ? "*" : processName).ValidateAndEscape("/?\"<>|}{");
                assemblyName = assemblyName.ValidateAndEscape();
                className    = className.ValidateAndEscape();
            }

            var filter = new AssemblyAndClassFilter(processName, assemblyName, className);

            if (filterType == FilterType.Inclusion)
            {
                InclusionFilters.Add(filter);
            }

            if (filterType == FilterType.Exclusion)
            {
                ExclusionFilters.Add(filter);
            }
        }
Example #8
0
        public void AddFilter(string assemblyClassName)
        {
            string     assemblyName;
            string     className;
            FilterType filterType;

            GetAssemblyClassName(assemblyClassName, RegExFilters, out filterType, out assemblyName, out className);

            if (!RegExFilters)
            {
                assemblyName = assemblyName.ValidateAndEscape();
                className    = className.ValidateAndEscape();
            }

            var filter = new AssemblyAndClassFilter(assemblyName, className);

            if (filterType == FilterType.Inclusion)
            {
                InclusionFilters.Add(filter);
            }

            if (filterType == FilterType.Exclusion)
            {
                ExclusionFilters.Add(filter);
            }
        }
        /// <summary>
        /// 构造一个 <see cref="PhysicalStorageDirectoryContents"/>。
        /// </summary>
        /// <param name="directory">给定的目录。</param>
        /// <param name="filters">指定排除哪些文件或目录。</param>
        public PhysicalStorageDirectoryContents(string directory, ExclusionFilters filters)
        {
            _directory = directory.NotEmpty(nameof(directory));
            _filters   = filters;

            Exists = Directory.Exists(_directory);
        }
Example #10
0
        public bool InstrumentClass(string assemblyName, string className)
        {
            if (string.IsNullOrEmpty(assemblyName) || string.IsNullOrEmpty(className))
            {
                return(false);
            }

            var matchingExclusionFilters = ExclusionFilters.GetMatchingFiltersForAssemblyName(assemblyName);

            if (matchingExclusionFilters.Any(exclusionFilter => exclusionFilter.ClassName == ".*"))
            {
                return(false);
            }

            if (matchingExclusionFilters
                .Where(exclusionFilter => exclusionFilter.ClassName != ".*")
                .Any(exclusionFilter => exclusionFilter.IsMatchingClassName(className)))
            {
                return(false);
            }

            var matchingInclusionFilters = InclusionFilters.GetMatchingFiltersForAssemblyName(assemblyName);

            if (matchingInclusionFilters.Any(inclusionFilter => inclusionFilter.IsMatchingClassName(className)))
            {
                return(true);
            }

            return(false);
        }
Example #11
0
 private bool ExcludeProcessOrAssembly(string processName, string assemblyName, out IList <AssemblyAndClassFilter> matchingExclusionFilters)
 {
     matchingExclusionFilters = ExclusionFilters.GetMatchingFiltersForAssemblyName(assemblyName);
     return(matchingExclusionFilters.Any(
                exclusionFilter =>
                exclusionFilter.ClassName == ".*" &&
                (exclusionFilter.IsMatchingProcessName(processName))));
 }
Example #12
0
        private static PhysicalFilesWatcher CreateFileWatcher(string root, ExclusionFilters filters)
        {
            string environmentVariable = Environment.GetEnvironmentVariable("DOTNET_USE_POLLING_FILE_WATCHER");
            bool   pollForChanges      = string.Equals(environmentVariable, "1", StringComparison.Ordinal) || string.Equals(environmentVariable, "true", StringComparison.OrdinalIgnoreCase);

            root = PathUtils.EnsureTrailingSlash(Path.GetFullPath(root));
            return(new PhysicalFilesWatcher(root, new FileSystemWatcher(root), pollForChanges, filters));
        }
 public static PhysicalFileProvider Create(string root, ExclusionFilters filters)
 {
     if (!Directory.Exists(root))
     {
         _ = Directory.CreateDirectory(root);
     }
     return(new PhysicalFileProvider(root, filters));
 }
        public void FiltersExcludedFiles(string filename, FileAttributes attributes, ExclusionFilters filters, bool excluded)
        {
            var fileInfo = new FileInfo(Path.Combine(_fileSystem.RootPath, filename));

            _fileSystem.CreateFile(fileInfo);
            fileInfo.Attributes = attributes;

            Assert.Equal(excluded, FileSystemInfoHelper.IsExcluded(_fileSystem.GetFile(filename), filters));
        }
        /// <summary>Creates file watcher.</summary>
        /// <param name="root">     The root directory. This should be an absolute path. </param>
        /// <param name="filters">  Specifies which files or directories are excluded. </param>
        /// <returns>The new file watcher.</returns>
        private static PhysicalFilesWatcher CreateFileWatcher(string root, ExclusionFilters filters)
        {
            var environmentValue = Environment.GetEnvironmentVariable(PollingEnvironmentKey);
            var pollForChanges   = string.Equals(environmentValue, "1", StringComparison.Ordinal) ||
                                   string.Equals(environmentValue, "true", StringComparison.OrdinalIgnoreCase);

            root = PathUtils.EnsureTrailingSlash(Path.GetFullPath(root));
            return(new PhysicalFilesWatcher(root, new FileSystemWatcher(root), pollForChanges, filters));
        }
Example #16
0
        private bool IsProcessExcluded(string processName)
        {
            if (!ExclusionFilters.Any())
            {
                return(false);
            }

            var matchingExclusionFilters = ExclusionFilters.GetMatchingFiltersForProcessName(processName);

            // Excluded by all filters
            return(matchingExclusionFilters.Any(exclusionFilter => (exclusionFilter.AssemblyName == ".*" && exclusionFilter.ClassName == ".*")));
        }
        public static void AddPhysical(
            [NotNull] this VirtualFileSetList list,
            [NotNull] string root,
            ExclusionFilters exclusionFilters = ExclusionFilters.Sensitive)
        {
            Check.NotNull(list, nameof(list));
            Check.NotNullOrWhiteSpace(root, nameof(root));

            var fileProvider = new PhysicalFileProvider(root, exclusionFilters);

            list.Add(new PhysicalVirtualFileSetInfo(fileProvider, root));
        }
Example #18
0
        public void FiltersExcludedFiles(string filename, FileAttributes attributes, ExclusionFilters filters, bool excluded)
        {
            using var fileSystem = new TempDirectory(GetTestFilePath());
            var fileInfo = new FileInfo(Path.Combine(fileSystem.Path, filename));

            using (var stream = fileInfo.Create())
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write("temp");
                }

            fileInfo.Attributes = attributes;

            Assert.Equal(excluded, FileSystemInfoHelper.IsExcluded(fileInfo, filters));
        }
Example #19
0
        private PhysicalFileProvider(string root, PhysicalFilesWatcher physicalFilesWatcher, ExclusionFilters filters)
        {
            if (!Path.IsPathRooted(root))
            {
                throw new ArgumentException("The path must be absolute.", nameof(root));
            }

            Root = PathUtils.EnsureTrailingSlash(Path.GetFullPath(root));
            if (!Directory.Exists(Root))
            {
                throw new DirectoryNotFoundException(Root);
            }

            _filesWatcher = physicalFilesWatcher;
            _filters      = filters;
        }
Example #20
0
        /// <summary>
        /// Should we instrument this asssembly
        /// </summary>
        /// <param name="processPath"></param>
        /// <returns></returns>
        public bool InstrumentProcess(string processPath)
        {
            if (string.IsNullOrEmpty(processPath))
            {
                return(false);
            }
            if (!ExclusionFilters.Any() && !InclusionFilters.Any())
            {
                return(true);
            }

            var processName = Path.GetFileNameWithoutExtension(processPath); // can return null!

            if (ExclusionFilters.Any())
            {
                var matchingExclusionFilters = new List <AssemblyAndClassFilter>(ExclusionFilters.GetMatchingFiltersForProcessName(processPath));
                if (!string.IsNullOrWhiteSpace(processName) && processName != processPath)
                {
                    matchingExclusionFilters.AddRange(ExclusionFilters.GetMatchingFiltersForProcessName(processName));
                }
                if (matchingExclusionFilters.Any
                        (exclusionFilter =>
                        // class-filter is .* and assembly-filter is matching processName
                        // this does not match default exclude filters like {.*}[mscorlib].* or {.*}[system].*
                        // but does match {.*}[.*].* or {.*}[processNa*].* or {.*}[processName].* where assemblyName == processName
                        exclusionFilter.ClassName == ".*" && exclusionFilter.IsMatchingAssemblyName(processName)
                        )
                    )
                {
                    return(false);
                }
            }

            if (InclusionFilters.Any())
            {
                var matchingInclusionFilters = new List <AssemblyAndClassFilter>(InclusionFilters.GetMatchingFiltersForProcessName(processPath));
                if (!string.IsNullOrWhiteSpace(processName) && processName != processPath)
                {
                    matchingInclusionFilters.AddRange(InclusionFilters.GetMatchingFiltersForProcessName(processName));
                }
                return(matchingInclusionFilters.Any());
            }

            return(true); // not excluded and no inclusion filters
        }
        /// <summary>Constructor.</summary>
        /// <exception cref="ArgumentException">            Thrown when one or more arguments have
        ///                                                 unsupported or illegal values. </exception>
        /// <exception cref="DirectoryNotFoundException">   Thrown when the requested directory is not
        ///                                                 present. </exception>
        /// <param name="root">                 The root directory. This should be an absolute path. </param>
        /// <param name="physicalFilesWatcher"> The physical files watcher. </param>
        /// <param name="filters">              Specifies which files or directories are excluded. </param>
        private LanguageAwarePhysicalFileProvider(string root, PhysicalFilesWatcher physicalFilesWatcher, ExclusionFilters filters)
        {
            if (!Path.IsPathRooted(root))
            {
                throw new ArgumentException("The path must be absolute.", nameof(root));
            }
            var fullRoot = Path.GetFullPath(root);

            // When we do matches in GetFullPath, we want to only match full directory names.
            Root = PathUtils.EnsureTrailingSlash(fullRoot);
            if (!Directory.Exists(Root))
            {
                throw new DirectoryNotFoundException(Root);
            }

            _filesWatcher = physicalFilesWatcher;
            _filters      = filters;
        }
        /// <summary>
        /// Initializes an instance of <see cref="PhysicalFilesWatcher" /> that watches files in <paramref name="root" />.
        /// Wraps an instance of <see cref="System.IO.FileSystemWatcher" />
        /// </summary>
        /// <param name="root">Root directory for the watcher</param>
        /// <param name="fileSystemWatcher">The wrapped watcher that is watching <paramref name="root" /></param>
        /// <param name="pollForChanges">
        /// True when the watcher should use polling to trigger instances of
        /// <see cref="IChangeToken" /> created by <see cref="CreateFileChangeToken(string)" />
        /// </param>
        /// <param name="filters">Specifies which files or directories are excluded. Notifications of changes to are not raised to these.</param>
        public PhysicalFilesWatcher(
            string root,
            FileSystemWatcher fileSystemWatcher,
            bool pollForChanges,
            ExclusionFilters filters)
        {
            _root        = root;
            _fileWatcher = fileSystemWatcher;
            _fileWatcher.IncludeSubdirectories = true;
            _fileWatcher.Created += OnChanged;
            _fileWatcher.Changed += OnChanged;
            _fileWatcher.Renamed += OnRenamed;
            _fileWatcher.Deleted += OnChanged;
            _fileWatcher.Error   += OnError;

            _pollForChanges = pollForChanges;
            _filters        = filters;
        }
Example #23
0
        public bool InstrumentProcess(string processName)
        {
            if (string.IsNullOrEmpty(processName))
            {
                return(false);
            }

            processName = Path.GetFileNameWithoutExtension(processName);
            var matchingExclusionFilters = ExclusionFilters.GetMatchingFiltersForProcessName(processName);

            if (matchingExclusionFilters.Any(exclusionFilter => exclusionFilter.AssemblyName == ".*" && exclusionFilter.ClassName == ".*"))
            {
                return(false);
            }

            var matchingInclusionFilters = InclusionFilters.GetMatchingFiltersForProcessName(processName);

            return(matchingInclusionFilters.Any(inclusionFilter => inclusionFilter.AssemblyName == ".*" || inclusionFilter.ClassName == ".*"));
        }
Example #24
0
        /// <summary>
        /// Initializes a new instance of a PhysicalFileProvider at the given root directory.
        /// </summary>
        /// <param name="root">The root directory. This should be an absolute path.</param>
        /// <param name="filters">Specifies which files or directories are excluded.</param>
        public PhysicalFileProvider(string root, ExclusionFilters filters)
        {
            if (!Path.IsPathRooted(root))
            {
                throw new ArgumentException("The path must be absolute.", nameof(root));
            }

            string fullRoot = Path.GetFullPath(root);

            // When we do matches in GetFullPath, we want to only match full directory names.
            Root = PathUtils.EnsureTrailingSlash(fullRoot);
            if (!Directory.Exists(Root))
            {
                throw new DirectoryNotFoundException(Root);
            }

            _filters            = filters;
            _fileWatcherFactory = () => CreateFileWatcher();
        }
Example #25
0
        public static bool IsExcluded(FileSystemInfo fileSystemInfo, ExclusionFilters filters)
        {
            if (filters == ExclusionFilters.None)
            {
                return(false);
            }
            else if (fileSystemInfo.Name.StartsWith(".", StringComparison.Ordinal) && (filters & ExclusionFilters.DotPrefixed) != 0)
            {
                return(true);
            }
            else if (fileSystemInfo.Exists &&
                     (((fileSystemInfo.Attributes & FileAttributes.Hidden) != 0 && (filters & ExclusionFilters.Hidden) != 0) ||
                      ((fileSystemInfo.Attributes & FileAttributes.System) != 0 && (filters & ExclusionFilters.System) != 0)))
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Initializes an instance of <see cref="PhysicalFilesWatcher" /> that watches files in <paramref name="root" />.
        /// Wraps an instance of <see cref="System.IO.FileSystemWatcher" />
        /// </summary>
        /// <param name="root">Root directory for the watcher</param>
        /// <param name="fileSystemWatcher">The wrapped watcher that is watching <paramref name="root" /></param>
        /// <param name="pollForChanges">
        /// True when the watcher should use polling to trigger instances of
        /// <see cref="IChangeToken" /> created by <see cref="CreateFileChangeToken(string)" />
        /// </param>
        /// <param name="filters">Specifies which files or directories are excluded. Notifications of changes to are not raised to these.</param>
        public PhysicalFilesWatcher(
            string root,
            FileSystemWatcher fileSystemWatcher,
            bool pollForChanges,
            ExclusionFilters filters)
        {
            _root        = root;
            _fileWatcher = fileSystemWatcher;
            _fileWatcher.IncludeSubdirectories = true;
            _fileWatcher.Created += OnChanged;
            _fileWatcher.Changed += OnChanged;
            _fileWatcher.Renamed += OnRenamed;
            _fileWatcher.Deleted += OnChanged;
            _fileWatcher.Error   += OnError;

            PollForChanges = pollForChanges;
            _filters       = filters;

            PollingChangeTokens = new ConcurrentDictionary <IPollingChangeToken, IPollingChangeToken>();
            _timerFactory       = () => NonCapturingTimer.Create(RaiseChangeEvents, state: PollingChangeTokens, dueTime: TimeSpan.Zero, period: DefaultPollingInterval);
        }
Example #27
0
        public bool UseAssembly(string assemblyName)
        {
            var matchingExclusionFilters = ExclusionFilters.GetMatchingFiltersForAssemblyName(assemblyName);

            if (matchingExclusionFilters.Any(exclusionFilter => exclusionFilter.ClassName == ".*"))
            {
                return(false);
            }

            if (matchingExclusionFilters.Any(exclusionFilter => exclusionFilter.ClassName != ".*"))
            {
                return(true);
            }

            var matchingInclusionFilters = InclusionFilters.GetMatchingFiltersForAssemblyName(assemblyName);

            if (matchingInclusionFilters.Any())
            {
                return(true);
            }

            return(false);
        }
Example #28
0
        /// <summary>
        /// Initializes an instance of <see cref="PhysicalFilesWatcher" /> that watches files in <paramref name="root" />.
        /// Wraps an instance of <see cref="System.IO.FileSystemWatcher" />
        /// </summary>
        /// <param name="root">Root directory for the watcher</param>
        /// <param name="fileSystemWatcher">The wrapped watcher that is watching <paramref name="root" /></param>
        /// <param name="pollForChanges">
        /// True when the watcher should use polling to trigger instances of
        /// <see cref="IChangeToken" /> created by <see cref="CreateFileChangeToken(string)" />
        /// </param>
        /// <param name="filters">Specifies which files or directories are excluded. Notifications of changes to are not raised to these.</param>
        public PhysicalFilesWatcher(
            string root,
            FileSystemWatcher fileSystemWatcher,
            bool pollForChanges,
            ExclusionFilters filters)
        {
            if (fileSystemWatcher == null && !pollForChanges)
            {
                throw new ArgumentNullException(nameof(fileSystemWatcher), SR.Error_FileSystemWatcherRequiredWithoutPolling);
            }

            _root = root;

            if (fileSystemWatcher != null)
            {
#if NETCOREAPP
                if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS())
                {
                    throw new PlatformNotSupportedException(SR.Format(SR.FileSystemWatcher_PlatformNotSupported, typeof(FileSystemWatcher)));
                }
#endif

                _fileWatcher = fileSystemWatcher;
                _fileWatcher.IncludeSubdirectories = true;
                _fileWatcher.Created += OnChanged;
                _fileWatcher.Changed += OnChanged;
                _fileWatcher.Renamed += OnRenamed;
                _fileWatcher.Deleted += OnChanged;
                _fileWatcher.Error   += OnError;
            }

            PollForChanges = pollForChanges;
            _filters       = filters;

            PollingChangeTokens = new ConcurrentDictionary <IPollingChangeToken, IPollingChangeToken>();
            _timerFactory       = () => NonCapturingTimer.Create(RaiseChangeEvents, state: PollingChangeTokens, dueTime: TimeSpan.Zero, period: DefaultPollingInterval);
        }
Example #29
0
        /// <summary>
        /// Decides whether an assembly should be included in the instrumentation
        /// </summary>
        /// <param name="processName">The name of the process being profiled</param>
        /// <param name="assemblyName">the name of the assembly under profile</param>
        /// <remarks>All assemblies matching either the inclusion or exclusion filter should be included
        /// as it is the class that is being filtered within these unless the class filter is *</remarks>
        public bool UseAssembly(string processName, string assemblyName)
        {
            processName = Path.GetFileNameWithoutExtension(processName);
            var matchingExclusionFilters = ExclusionFilters.GetMatchingFiltersForAssemblyName(assemblyName);

            if (matchingExclusionFilters.Any(exclusionFilter => exclusionFilter.ClassName == ".*" && exclusionFilter.IsMatchingProcessName(processName)))
            {
                return(false);
            }

            if (matchingExclusionFilters.Any(exclusionFilter => exclusionFilter.ClassName != ".*"))
            {
                return(true);
            }

            var matchingInclusionFilters = InclusionFilters.GetMatchingFiltersForAssemblyName(assemblyName);

            if (matchingInclusionFilters.Any())
            {
                return(true);
            }

            return(false);
        }
Example #30
0
 public DefaultMediaFileStoreCacheFileProvider(ILogger <DefaultMediaFileStoreCacheFileProvider> logger, PathString virtualPathBase, string root, ExclusionFilters filters) : base(root, filters)
 {
     _logger         = logger;
     VirtualPathBase = virtualPathBase;
 }