当前位置: 首页>>代码示例>>C#>>正文


C# Project.AttachBuildListeners方法代码示例

本文整理汇总了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);
        }
开发者ID:anelson,项目名称:multitask,代码行数:15,代码来源:LogEventQueueBase.cs

示例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);
        }
开发者ID:dguder,项目名称:nant,代码行数:71,代码来源:ConsoleDriver.cs


注:本文中的NAnt.Core.Project.AttachBuildListeners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。