private static IEnumerable <FileChangeInstruction> GetFileChangeInstructions(
     DeployCmdLineArgs cmdLineArgs,
     XmlNodeList elements,
     Func <XmlElement, IEnumerable <IChangeInstruction> > getInstructions)
 {
     return(from XmlElement element in elements
            let filenameMatches = (element.HasAttribute("match")
                                     ? element.GetAttribute("match")
                                     : "*.*")
                                  .Split(new[] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries)
                                  let ancestorFolders = element.GetAttribute("ancestor-folder").Split(new[] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries)
                                                        select new FileChangeInstruction(
                getInstructions(element),
                new PatternMatchingConfigFilesLocator(cmdLineArgs.ConfigFilesLocation, ancestorFolders, filenameMatches)));
 }
        public IEnumerable <FileChangeInstruction> Parse(DeployCmdLineArgs cmdLineArgs)
        {
            foreach (string file in Directory.GetFiles(cmdLineArgs.InstructionsFilesLocation, _fileMatch))
            {
                var doc = new XmlDocument();
                doc.Load(file);

                var ret = GetFileChangeInstructions(cmdLineArgs, doc.SelectNodes("//Files/File"), GetXmlChangeInstructions)
                          .Union(GetFileChangeInstructions(cmdLineArgs, doc.SelectNodes("//Replacements"), GetReplacementInstructions));

                foreach (var retItem in ret)
                {
                    yield return(retItem);
                }
            }
        }