private static void AppendAntFileNodes(Target target, List<XObject> targetDescendants) { var regex = new Regex(AntFileSpliter, RegexOptions.Compiled); var antFileRefs = target.Dependencies.Where(t => regex.IsMatch(t)).Select(t => { var match = regex.Match(t); return new { Resource = match.Groups["importedfile"].Value, Target = match.Groups["target"].Value }; }); foreach (var antFileRef in antFileRefs) { var antElement = new XElement("ant", new XAttribute("antfile", antFileRef.Resource)); if (!string.IsNullOrWhiteSpace(antFileRef.Target)) { antElement.Add(new XAttribute("target", antFileRef.Target)); } targetDescendants.Add(antElement); } }
private static void AppendAntCallNodes(Target target, List<XObject> targetDescendants) { var callees = target.Dependencies.Where( t => t.StartsWith(AntCalMarker) ).Select( t => t.Substring(1) ); foreach (var callee in callees) { targetDescendants.Add(new XElement("antcall", new XAttribute("target", callee))); } }
private static XObject[] CollectDependencies(Target target, List<XObject> targetDescendants) { AppendAntCallNodes(target, targetDescendants); AppendAntFileNodes(target, targetDescendants); return targetDescendants.ToArray(); }
private static XAttribute DependsAttribute(Target t, IFormater formater) { var referencedByDependsAttr = t.Dependencies.Where(IsExplicitDepencency).Select( d => d.StartsWith("*") ? d.Substring(1) :d ); if (referencedByDependsAttr.Count() == 0) return null; return new XAttribute("depends", string.Join(",", referencedByDependsAttr.Select(d => TargetNameFromFullQualifiedDependency(d)).Select( n => formater.FormatTargetName(n))) ); }
private static List<XObject> AttributesFor(Target target, IFormater formater) { List<XObject> attributes = new List<XObject>(); attributes.Add(new XAttribute("name", target.Name)); var dependencies = DependsAttribute(target, formater); if (dependencies != null) { attributes.Add(dependencies); } return attributes; }