本文整理汇总了C#中NAnt.Core.Project.CreateTask方法的典型用法代码示例。如果您正苦于以下问题:C# Project.CreateTask方法的具体用法?C# Project.CreateTask怎么用?C# Project.CreateTask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NAnt.Core.Project
的用法示例。
在下文中一共展示了Project.CreateTask方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddReadRegistrys
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);
}
}
}
}
示例2: LoadStyleCopCmdTask
/// <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));
}
示例3: ParseTstamps
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
}
}
}
}
示例4: CreateTask
/// <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;
}