當前位置: 首頁>>代碼示例>>C#>>正文


C# Project.CreateTask方法代碼示例

本文整理匯總了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);
                    }
                }
            }
        }
開發者ID:BackupTheBerlios,項目名稱:nantgui,代碼行數:26,代碼來源:NAntBuildScript.cs

示例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));
        }
開發者ID:hugener,項目名稱:StyleCopCmd,代碼行數:25,代碼來源:StyleCopCmdTaskTest.cs

示例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
                    }
                }
            }
        }
開發者ID:BackupTheBerlios,項目名稱:nantgui,代碼行數:27,代碼來源:NAntBuildScript.cs

示例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;
        }
開發者ID:hugener,項目名稱:StyleCopCmd,代碼行數:14,代碼來源:StyleCopCmdTaskTest.cs


注:本文中的NAnt.Core.Project.CreateTask方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。