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


C# Project.Log方法代碼示例

本文整理匯總了C#中NAnt.Core.Project.Log方法的典型用法代碼示例。如果您正苦於以下問題:C# Project.Log方法的具體用法?C# Project.Log怎麽用?C# Project.Log使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NAnt.Core.Project的用法示例。


在下文中一共展示了Project.Log方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateTask

        /// <summary> 
        /// Creates a new <see cref="Task" /> instance for the given XML and 
        /// <see cref="Project" />.
        /// </summary>
        /// <param name="taskNode">The XML to initialize the task with.</param>
        /// <param name="proj">The <see cref="Project" /> that the <see cref="Task" /> belongs to.</param>
        /// <returns>
        /// The new <see cref="Task" /> instance.
        /// </returns>
        public static Task CreateTask(XmlNode taskNode, Project proj)
        {
            if (taskNode == null) {
                throw new ArgumentNullException("taskNode");
            }
            if (proj == null) {
                throw new ArgumentNullException("proj");
            }

            string taskName = taskNode.Name;

            TaskBuilder builder = TaskBuilders[taskName];
            if (builder == null) {
                Location location = proj.LocationMap.GetLocation(taskNode);
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    ResourceUtils.GetString("NA1083"), taskName), location);
            }

            Task task = builder.CreateTask();
            task.Project = proj;
            task.NamespaceManager = proj.NamespaceManager;

            // check whether the task (or its base class) is deprecated
            ObsoleteAttribute obsoleteAttribute = (ObsoleteAttribute)
                Attribute.GetCustomAttribute(task.GetType(),
                typeof(ObsoleteAttribute), true);

            if (obsoleteAttribute != null) {
                Location location = proj.LocationMap.GetLocation(taskNode);
                string obsoleteMessage = string.Format(CultureInfo.InvariantCulture,
                    ResourceUtils.GetString("NA1086"), taskName,
                    obsoleteAttribute.Message);
                if (obsoleteAttribute.IsError) {
                    throw new BuildException(obsoleteMessage, location);
                } else {
                    proj.Log(Level.Warning, "{0} {1}", location, obsoleteMessage);
                }
            }

            return task;
        }
開發者ID:julianhaslinger,項目名稱:nant,代碼行數:50,代碼來源:TypeFactory.cs

示例2: CheckDeprecation

        private static void CheckDeprecation(string functionName, MethodInfo function, Project project)
        {
            // check whether the function is deprecated
            ObsoleteAttribute obsoleteAttribute = (ObsoleteAttribute)
                Attribute.GetCustomAttribute(function,
                typeof(ObsoleteAttribute), true);

            // if function itself is not deprecated, check if its declaring
            // type is deprecated
            if (obsoleteAttribute == null) {
                obsoleteAttribute = (ObsoleteAttribute)
                    Attribute.GetCustomAttribute(function.DeclaringType,
                    typeof(ObsoleteAttribute), true);
            }

            if (obsoleteAttribute != null) {
                string obsoleteMessage = string.Format(CultureInfo.InvariantCulture,
                    ResourceUtils.GetString("NA1087"), functionName,
                    obsoleteAttribute.Message);
                if (obsoleteAttribute.IsError) {
                    throw new BuildException(obsoleteMessage, Location.UnknownLocation);
                } else {
                    project.Log(Level.Warning, "{0}", obsoleteMessage);
                }
            }
        }
開發者ID:julianhaslinger,項目名稱:nant,代碼行數:26,代碼來源:TypeFactory.cs

示例3: CreateDataType

        public static DataTypeBase CreateDataType(XmlNode elementNode, Project proj)
        {
            if (elementNode == null) {
                throw new ArgumentNullException("elementNode");
            }
            if (proj == null) {
                throw new ArgumentNullException("proj");
            }

            string dataTypeName = elementNode.Name;

            DataTypeBaseBuilder builder = DataTypeBuilders[dataTypeName];
            if (builder == null) {
                Location location = proj.LocationMap.GetLocation(elementNode);
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    ResourceUtils.GetString("NA1081"), dataTypeName), location);
            }

            DataTypeBase element = (DataTypeBase) builder.CreateDataTypeBase();
            element.Project = proj;
            element.NamespaceManager = proj.NamespaceManager;

            // check whether the type (or its base class) is deprecated
            ObsoleteAttribute obsoleteAttribute = (ObsoleteAttribute)
                Attribute.GetCustomAttribute(element.GetType(),
                typeof(ObsoleteAttribute), true);

            if (obsoleteAttribute != null) {
                Location location = proj.LocationMap.GetLocation(elementNode);
                string obsoleteMessage = string.Format(CultureInfo.InvariantCulture,
                    ResourceUtils.GetString("NA1085"), dataTypeName,
                    obsoleteAttribute.Message);
                if (obsoleteAttribute.IsError) {
                    throw new BuildException(obsoleteMessage, location);
                } else {
                    proj.Log(Level.Warning, "{0} {1}", location, obsoleteMessage);
                }
            }
            return element;
        }
開發者ID:julianhaslinger,項目名稱:nant,代碼行數:40,代碼來源:TypeFactory.cs


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