Ejemplo n.º 1
0
 public void TransformDirectory(string path, FileFilter filter)
 {
     foreach (var fileInfo in this.fileSystem.AllFiles(path, filter))
     {
         this.TransformFile(fileInfo);
     }
 }
        public static ResourceList ParseAllResourceFiles(IFileSystem fileSystem, string path, ResourceFilter resourceFilter = null)
        {
            var resourceList = new ResourceList();

            var fileFilter = new FileFilter { FileExtensionWhitelist = new Regex(@"\.resx$") };

            foreach (var file in fileSystem.AllFiles(path, fileFilter))
            {
                var xml = fileSystem.LoadXmlFile(file.FullName);
                resourceList.Merge(ParseAsResourceList(xml, resourceFilter));
            }

            return resourceList;
        }
Ejemplo n.º 3
0
        public IEnumerable<FileInfo> AllFiles(
            string rootPath,
            FileFilter filter)
        {
            if (string.IsNullOrEmpty(rootPath))
            {
                throw new ArgumentNullException("rootPath", "Must provide a root path.");
            }

            // Iterate through all files from provided path
            var root = new DirectoryInfo(rootPath);

            var subDirectories = root.GetDirectories("*.*", SearchOption.AllDirectories);

            // Make sure we include the root when enumerating the files of each directory
            var directories = new List<DirectoryInfo>(capacity: subDirectories.Count() + 1) { root };
            directories.AddRange(subDirectories);

            // Walk all of the directories
            foreach (var dir in directories)
            {
                if (filter.DirectoryBlacklist.IsMatch(dir.FullName))
                {
                    continue;
                }

                var files = dir.GetFiles("*.*");

                foreach (var file in files)
                {
                    if (!filter.IsMatch(file.Name))
                    {
                        continue;
                    }

                    yield return file;
                }
            }
        }