Example #1
0
        internal override void ManageFolders(IFileSystem fileSystem)
        {
            if (Folders != null)
            {
                // helper list to be able to modify Folders property inside the loop
                var iterate = new List<FolderInfo>(Folders);

                foreach (var folder in iterate)
                {
                    if (fileSystem.Exists(this, folder))
                    {
                        var directoryInfos = fileSystem.GetFolders(this, folder);
                        foreach (var directoryInfo in directoryInfos.OrderByDescending(x => x.Name))
                        {
                            var newFolder = new FolderInfo
                            {
                                Absolute = folder.Absolute,
                                Filter = folder.Filter,
                                Levels = new List<LogLevel>(folder.Levels),
                                Name = $"{folder.Name}_{directoryInfo.Name}",
                                Path = fileSystem.CombinePath(folder.Path, directoryInfo.Name),
                                OpeningLinePattern = folder.OpeningLinePattern
                            };

                            Folders.Insert(Folders.IndexOf(folder) + 1, newFolder);
                        }
                    }
                    else
                    {
                        Folders.Remove(folder);
                    }
                }
            }
        }
Example #2
0
 public List<FileInfo> GetFiles(HostInfo host, FolderInfo directory)
 {
     var directoryInfo = GetDirectoryInfo(host, directory);
     if (directoryInfo.Exists)
     {
         return directoryInfo.GetFiles(directory.Filter ?? "*").ToList();
     }
     return new List<FileInfo>();
 }
Example #3
0
 public List<DirectoryInfo> GetFolders(HostInfo host, FolderInfo directory)
 {
     if (!string.IsNullOrWhiteSpace(directory.SubfolderSearchPattern))
     {
         var directoryInfo = GetDirectoryInfo(host, directory);
         if (directoryInfo.Exists)
         {
             return directoryInfo.GetDirectories(directory.SubfolderSearchPattern).ToList();
         }
     }
     return new List<DirectoryInfo>();
 }
Example #4
0
        public FileLogSource(string fullPath, FolderInfo folderInfo)
        {
            FullPath = fullPath;
            OpeningLinePattern = folderInfo.OpeningLinePattern;

            if (folderInfo.Levels != null)
            {
                LogLevels = new Dictionary<string, Regex>();
                foreach (var level in folderInfo.Levels)
                {
                    LogLevels.Add(level.Name, new Regex(level.Regex, GetOptions(level)));
                }
            }
        }
Example #5
0
 private string GetDirectoryPath(HostInfo host, FolderInfo directory)
 {
     return directory.Absolute ? directory.Path : GetUncDirectory(host.Unc, directory.Path);
 }
Example #6
0
 private DirectoryInfo GetDirectoryInfo(HostInfo host, FolderInfo directory)
 {
     string directoryPath = GetDirectoryPath(host, directory);
     return new DirectoryInfo(directoryPath);
 }
Example #7
0
 public bool Exists(HostInfo host, FolderInfo directory)
 {
     return GetDirectoryInfo(host, directory).Exists;
 }