TaskItem 类

定义

定义项目中传递到任务的单个项。Defines a single item of the project as it is passed into a task.

public ref class TaskItem sealed : MarshalByRefObject, Microsoft::Build::Framework::ITaskItem2
public sealed class TaskItem : MarshalByRefObject, Microsoft.Build.Framework.ITaskItem2
type TaskItem = class
    inherit MarshalByRefObject
    interface ITaskItem
    interface ITaskItem2
Public NotInheritable Class TaskItem
Inherits MarshalByRefObject
Implements ITaskItem2
继承
实现

注解

TaskItem对象与项目文件中的项元素不完全对应。TaskItem objects do not exactly correspond to item elements in project files. 如果是这样, 则任务将无法访问通过项目文件显式传递到任务的数据。If they did, then tasks would have access to data that was not explicitly passed into the task through the project file. 这并不是安全问题, 而是项目文件的清晰度和透明性问题。This is not a security issue, but rather an issue with project file clarity and transparency.

此类必须是密封的, 因为生成引擎实例化其自己的此类型的副本。This class has to be sealed since the build engine instantiates its own copy of this type. 如果第三方正在扩展此类, 则生成引擎将产生意外的行为。If a third party were to extend this class, then the build engine will yield an undesired behavior.

构造函数

TaskItem()

初始化 TaskItem 类的新实例。Initializes a new instance of the TaskItem class.

TaskItem(ITaskItem)

使用指定的源 TaskItem 初始化 ITaskItem 类的新实例。Initializes a new instance of the TaskItem class using the specified source ITaskItem.

TaskItem(String)

使用指定的项规范字符串初始化 TaskItem 类的新实例。Initializes a new instance of the TaskItem class using the specified item-specification string.

TaskItem(String, IDictionary)

使用指定的项规范字符串及其元数据初始化 TaskItem 类的新实例。Initializes a new instance of the TaskItem class using the specified item-specification string and its metadata.

属性

ItemSpec

获取或设置项规范。Gets or sets the item specification.

MetadataCount

获取在该项上设置的元数据的数目。Gets the number of metadata set on the item.

MetadataNames

获取该项的所有元数据的名称。Gets the names of all the metadata on the item.

方法

CloneCustomMetadata()

克隆项规范的自定义元数据的集合。Clones the collection of custom metadata for the item specification.

CopyMetadataTo(ITaskItem)

将项规范的元数据复制到指定的目标任务项。Copies the item-specification metadata to the specified destination task item.

CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetMetadata(String)

检索该项的指定元数据。Retrieves the specified metadata on the item.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

当在派生类中被重写时,赋予任务项无限期的租约时间。When overridden in a derived class, gives task items infinite lease time.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
RemoveMetadata(String)

移除该项的指定元数据。Removes the specified metadata on the item.

SetMetadata(String, String)

设置或修改该项的指定元数据的值。Sets or modifies the value of the specified metadata on the item.

ToString()

获取项规范。Gets the item specification.

运算符

Explicit(TaskItem to String)

允许将显式类型从 TaskItem 强制转换为 String,并返回该项的 ItemSpecAllows an explicit type cast from a TaskItem to a String, and returns the ItemSpec for that item.

显式接口实现

ITaskItem2.CloneCustomMetadataEscaped()

可返回此对象的元数据克隆的 ITaskItem2 实现。ITaskItem2 implementation which returns a clone of the metadata on this object. 返回的值采用其原始的转义形式。Values returned are in their original escaped form.

ITaskItem2.EvaluatedIncludeEscaped

用于获取或设置项包含值的 ITaskItem2 实现。ITaskItem2 implementation which gets or sets the item include value. 对于基于磁盘的项,这将是文件路径。For disk-based items this would be the file path.

ITaskItem2.GetMetadataValueEscaped(String)

允许查询此项的元数据值的 ITaskItem2 实现。ITaskItem2 implementation which allows the values of metadata on the item to be queried.

ITaskItem2.SetMetadataValueLiteral(String, String)

允许在此项上设置自定义元数据的 ITaskItem2 实现。ITaskItem2 implementation which allows a piece of custom metadata to be set on the item. 假定传入的值未经转义,并根据需要将值进行转义以维护其值。Assumes that the value passed in is unescaped, and escapes the value as necessary in order to maintain its value.

适用于