本文整理匯總了C#中NAnt.Core.Project.AttachBuildListeners方法的典型用法代碼示例。如果您正苦於以下問題:C# Project.AttachBuildListeners方法的具體用法?C# Project.AttachBuildListeners怎麽用?C# Project.AttachBuildListeners使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NAnt.Core.Project
的用法示例。
在下文中一共展示了Project.AttachBuildListeners方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Install
/// <summary>
/// Replaces existing build event handlers with a handler that enqueues
/// build events into this queue
/// </summary>
/// <param name="proj"></param>
public void Install(Project proj, String hideTarget)
{
_hideTarget = hideTarget;
BuildListenerCollection coll = new BuildListenerCollection();
coll.Add(this);
proj.DetachBuildListeners();
proj.AttachBuildListeners(coll);
}
示例2: AddBuildListeners
/// <summary>
/// Add the listeners specified in the command line arguments,
/// along with the default listener, to the specified project.
/// </summary>
/// <param name="cmdlineOptions">The command-line options.</param>
/// <param name="project">The <see cref="Project" /> to add listeners to.</param>
private static void AddBuildListeners(CommandLineOptions cmdlineOptions, Project project)
{
BuildListenerCollection listeners = new BuildListenerCollection();
IBuildLogger buildLogger = null;
TextWriter outputWriter = Console.Out;
if (cmdlineOptions.LogFile != null) {
try {
outputWriter = new StreamWriter(new FileStream(cmdlineOptions.LogFile.FullName, FileMode.Create, FileAccess.Write, FileShare.Read));
} catch (Exception ex) {
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
ResourceUtils.GetString("NA1005"), cmdlineOptions.LogFile.FullName),
Location.UnknownLocation, ex);
}
}
if (cmdlineOptions.LoggerType != null) {
try {
buildLogger = ConsoleDriver.CreateLogger(cmdlineOptions.LoggerType);
} catch (Exception ex) {
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
ResourceUtils.GetString("NA1003"), cmdlineOptions.LoggerType),
Location.UnknownLocation, ex);
}
}
// if no logger was specified on the commandline or an error occurred
// while creating an instance of the specified logger, use the default
// logger.
if (buildLogger == null) {
buildLogger = new DefaultLogger();
}
// only set OutputWriter if build logger does not derive from
// DefaultLogger, or if logfile was specified on command-line.
// Setting the OutputWriter of the DefaultLogger to Console.Out
// would cause issues with unit tests.
if (!typeof(DefaultLogger).IsAssignableFrom(buildLogger.GetType()) || cmdlineOptions.LogFile != null) {
buildLogger.OutputWriter = outputWriter;
}
// set threshold of build logger equal to threshold of project
buildLogger.Threshold = project.Threshold;
// set emacs mode
buildLogger.EmacsMode = cmdlineOptions.EmacsMode;
// add build logger to listeners collection
listeners.Add(buildLogger);
// add listeners to listener collection
foreach (string listenerTypeName in cmdlineOptions.Listeners) {
try {
IBuildListener listener = ConsoleDriver.CreateListener(listenerTypeName);
listeners.Add(listener);
} catch (Exception ex) {
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
ResourceUtils.GetString("NA1002"), listenerTypeName),
Location.UnknownLocation, ex);
}
}
// attach listeners to project
project.AttachBuildListeners(listeners);
}