TaskItem 類別

定義

此類別代表在傳遞至工作時專案的單一項目。This class represents a single item of the project, as it is passed into a task. TaskItems 不會完全對應至專案檔中的項目元素,因為這些工作可存取未透過專案檔明確傳遞至工作的資料。TaskItems do not exactly correspond to item elements in project files, because then tasks would have access to data that wasn't explicitly passed into the task via the project file. 這並不是安全性問題,而僅僅與專案檔的明確性與透明度相關。It's not a security issue, but more just an issue with project file clarity and transparency.

請注意:這個類別必須是密封的。Note: This class has to be sealed. 這個類別必須是密封的,因為引擎具現化其本身的此類型複本,因此如果將其延伸,則無法使引擎做出所需的行為。It has to be sealed because the engine instantiates it's own copy of this type and thus if someone were to extend it, they would not get the desired behavior from the engine.

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

備註

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()

預設建構函式 -- 我們需要此建構函式,因此其為 COM 可建立的類型。Default constructor -- we need it so this type is COM-createable.

TaskItem(ITaskItem)

這個建構函式會使用指定的 ITaskItem 來建立新 TaskItem。This constructor creates a new TaskItem, using the given ITaskItem.

TaskItem(String)

此建構函式會使用指定的項目規格來建立新工作項目。This constructor creates a new task item, given the item spec.

TaskItem(String, IDictionary)

此建構函式會使用指定的項目規格與中繼資料來建立新 TaskItem。This constructor creates a new TaskItem, using the given item spec and metadata.

屬性

ItemSpec

取得或設定項目規格。Gets or sets the item-spec.

MetadataCount

取得項目上已設定的中繼資料數目。Gets the number of metadata set on the item.

MetadataNames

取得所有項目中繼資料的名稱。Gets the names of all the item's metadata.

方法

CloneCustomMetadata()

取得自訂中繼資料的集合。Get the collection of custom metadata. 這不包含內建的中繼資料。This does not include built-in metadata.

CopyMetadataTo(ITaskItem)

將中繼資料 (但非 ItemSpec) 複製到 destinationItem。Copy the metadata (but not the ItemSpec) to destinationItem. 如果目的地項目上已有特定中繼資料,則不會將其覆寫 -- 優先採用原始值。If a particular metadata already exists on the destination item, then it is not overwritten -- the original value wins.

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。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()
已過時。

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
GetMetadata(String)

擷取項目上任意一個中繼資料。Retrieves one of the arbitrary metadata on the item. 如果找不到,則傳回空字串。If not found, returns empty string.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
InitializeLifetimeService()

覆寫以提供此類別無限的租用時間。Overridden to give this class infinite lease time. 否則,我們最終會獲得有限的租用 (我認為是 5 分鐘),且如果執行個體需要較長的時間處理,就會過期。Otherwise we end up with a limited lease (5 minutes I think) and instances can expire if they take long time processing.

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 one of the arbitrary metadata on the item.

SetMetadata(String, String)

設定項目上的任意一個中繼資料。Sets one of the arbitrary metadata on the item.

ToString()

取得項目規格。Gets the item-spec.

運算子

Explicit(TaskItem to String)

這會允許將 "TaskItem" 明確轉換為「字串」,並傳回這個項目的逸出 ItemSpec。This allows an explicit typecast from a "TaskItem" to a "string", returning the escaped ItemSpec for this 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

取得或設定項目的逸出包含或「名稱」。Gets or sets the escaped include, or "name", for the item.

ITaskItem2.GetMetadataValueEscaped(String)

傳回具有指定索引鍵的中繼資料其逸出值。Returns the escaped value of the metadata with the specified key.

ITaskItem2.SetMetadataValueLiteral(String, String)

設定具有指定名稱的中繼資料其逸出值。Sets the escaped value of the metadata with the specified name.

適用於