private void AddReadRegistrys(Project project, XmlDocument doc) { foreach (XmlElement element in doc.GetElementsByTagName("readregistry")) { if (TypeFactory.TaskBuilders.Contains(element.Name)) { ReadRegistryTask task = (ReadRegistryTask) project.CreateTask(element); task.Initialize(element); if (task.PropertyName != null) { task.Execute(); object val = task.Properties[task.PropertyName]; string value = val == null ? "" : val.ToString(); NAntProperty property = new NAntProperty( task.PropertyName, value, element.ParentNode.Attributes["name"].Value, false); property.ExpandedValue = property.Value; Properties.Add(property); } } } }
/// <summary> /// Load any custom tasks into the given project from the /// StyleCopCmd.Core assembly. /// </summary> /// <param name="project"> /// The project to load the custom tasks into. /// </param> private static void LoadStyleCopCmdTask(Project project) { if (project.Document.DocumentElement == null) { throw new XmlException("DocumentElement is null"); } // Add an echo task to the project's document root to output // the result of the task load operation. var et = project.Document.CreateElement("echo"); et.Attributes.Append(project.Document.CreateAttribute("message")); project.Document.DocumentElement.AppendChild(et); // Load the custom tasks. TypeFactory.ScanAssembly( Assembly.GetAssembly(typeof(StyleCopCmdTask)), project.CreateTask(et)); }
private void ParseTstamps(Project project, XmlDocument doc) { foreach (XmlElement element in doc.GetElementsByTagName("tstamp")) { if (TypeFactory.TaskBuilders.Contains(element.Name)) { TStampTask task = (TStampTask) project.CreateTask(element); task.Initialize(element); try { task.Execute(); NAntProperty property = new NAntProperty( task.Property, task.Properties[task.Property], element.ParentNode.Attributes["name"].Value, true); property.ExpandedValue = property.Value; Properties.Add(property); } catch (BuildException) { // TODO: Do something with the error message } } } }
/// <summary>Creates a StyleCopCmd task.</summary> /// <param name="project">The project to create the task from.</param> /// <returns>A StyleCopCmd task.</returns> private static StyleCopCmdTask CreateTask(Project project) { if (project.Document.DocumentElement == null) { throw new XmlException("DocumentElement is null"); } var el = project.Document.DocumentElement.ChildNodes[0]; var nt = (StyleCopCmdTask) project.CreateTask(el); return nt; }