本文整理汇总了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;
}
示例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);
}
}
}
示例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;
}