public IncludeFile GetIncludeFile(ProbeAppSettings appSettings, string sourceFileName, string fileName, bool searchSameDir, IEnumerable <string> parentFiles) { #if DEBUG if (parentFiles == null) { throw new ArgumentNullException("parentFiles"); } #endif if (string.IsNullOrEmpty(fileName)) { return(null); } // Check if the include file is cached. IncludeFile file = null; var fileNameLower = fileName.ToLower(); if (searchSameDir && !string.IsNullOrEmpty(sourceFileName)) { if (_sameDirIncludeFiles.TryGetValue(fileNameLower, out file)) { file.CheckForRefreshRequired(); return(file); } } if (_globalIncludeFiles.TryGetValue(fileNameLower, out file)) { file.CheckForRefreshRequired(); return(file); } // Search the disk in same directory. if (searchSameDir && !string.IsNullOrEmpty(sourceFileName)) { var pathName = Path.Combine(Path.GetDirectoryName(sourceFileName), fileName); if (File.Exists(pathName)) { if (CheckForCyclicalInclude(pathName, parentFiles)) { return(null); } file = new IncludeFile(this, pathName); _sameDirIncludeFiles[fileNameLower] = file; return(file); } } // Search the disk in global include directories. if (appSettings.Initialized) { foreach (var includeDir in appSettings.IncludeDirs) { var pathName = Path.Combine(includeDir, fileName); if (File.Exists(pathName)) { if (CheckForCyclicalInclude(pathName, parentFiles)) { return(null); } file = new IncludeFile(this, pathName); _globalIncludeFiles[fileNameLower] = file; return(file); } } } return(null); }