NativeActivity 類別

定義

使用 Execute(NativeActivityContext) 方法實作執行邏輯的自訂活動抽象基底類別,可完整存取執行階段的功能。Abstract base class for custom activities that implement execution logic using the Execute(NativeActivityContext) method, which has full access to the runtime's features.

public ref class NativeActivity abstract : System::Activities::Activity
public abstract class NativeActivity : System.Activities.Activity
type NativeActivity = class
    inherit Activity
Public MustInherit Class NativeActivity
Inherits Activity
繼承
NativeActivity
衍生

範例

下列程式碼範例將示範如何建立繼承自 NativeActivity<TResult> 的類別。The following code sample demonstrates creating a class that inherits from NativeActivity<TResult>. 這個範例來自于使用原生活動的自訂複合範例。This example is from the Custom Composite using Native Activity sample.

public sealed class MySequence : NativeActivity  
{  
    Collection<Activity> children;  
    Collection<Variable> variables;  
    Variable<int> currentIndex;  
    CompletionCallback onChildComplete;  
  
    public MySequence()  
        : base()  
    {  
        this.children = new Collection<Activity>();  
        this.variables = new Collection<Variable>();  
        this.currentIndex = new Variable<int>();  
    }  
  
    public Collection<Activity> Activities  
    {  
        get  
        {  
            return this.children;  
        }  
    }  
    public Collection<Variable> Variables  
    {  
        get  
        {  
            return this.variables;  
        }  
    }  
    protected override void CacheMetadata(NativeActivityMetadata metadata)  
    {  
        //call base.CacheMetadata to add the Activities and Variables to this activity's metadata  
        base.CacheMetadata(metadata);  
        //add the private implementation variable: currentIndex   
        metadata.AddImplementationVariable(this.currentIndex);  
    }                     
  
    protected override void Execute(NativeActivityContext context)  
    {  
        InternalExecute(context, null);  
    }  
    void InternalExecute(NativeActivityContext context, ActivityInstance instance)  
    {  
        //grab the index of the current Activity  
        int currentActivityIndex = this.currentIndex.Get(context);  
        if (currentActivityIndex == Activities.Count)  
        {  
            //if the currentActivityIndex is equal to the count of MySequence's Activities  
            //MySequence is complete  
            return;  
        }  
  
        if (this.onChildComplete == null)  
        {  
            //on completion of the current child, have the runtime call back on this method  
            this.onChildComplete = new CompletionCallback(InternalExecute);  
        }  
        //grab the next Activity in MySequence.Activities and schedule it  
        Activity nextChild = Activities[currentActivityIndex];  
        context.ScheduleActivity(nextChild, this.onChildComplete);  
  
        //increment the currentIndex  
        this.currentIndex.Set(context, ++currentActivityIndex);  
    }  
}  

建構函式

NativeActivity()

在衍生類別中實作時,建立衍生類別的新執行個體。When implemented in a derived class, creates a new instance of the derived class.

屬性

CacheId

取得工作流程定義範圍內的唯一快取識別碼。Gets the identifier of the cache that is unique within the scope of the workflow definition.

(繼承來源 Activity)
CanInduceIdle

取得或設定值,這個值指出此活動是否會造成工作流程變為閒置。Gets or sets a value that indicates whether the activity can cause the workflow to become idle.

Constraints

取得 Constraint 活動的集合,這些活動可以設定為提供 Activity 的驗證。Gets a collection of Constraint activities that can be configured to provide validation for the Activity.

(繼承來源 Activity)
DisplayName

取得或設定選擇性的易記名稱,這個名稱會用於偵錯、驗證、例外狀況處理及追蹤。Gets or sets an optional friendly name that is used for debugging, validation, exception handling, and tracking.

(繼承來源 Activity)
Id

取得工作流程定義範圍內的唯一識別碼。Gets an identifier that is unique in the scope of the workflow definition.

(繼承來源 Activity)
Implementation

活動的執行邏輯。The execution logic of the activity.

ImplementationVersion

取得或設定活動的實作版本。Gets or sets the implementation version of the activity.

方法

Abort(NativeActivityAbortContext)

在衍生類別中實作時,會採取動作以回應中止的活動。When implemented in a derived class, takes actions in response to the activity being aborted.

CacheMetadata(ActivityMetadata)

未實作。Not implemented. 請改用 CacheMetadata(NativeActivityMetadata) 方法。Use the CacheMetadata(NativeActivityMetadata) method instead.

CacheMetadata(NativeActivityMetadata)

建立並驗證活動引數、變數、子活動和活動委派的描述。Creates and validates a description of the activity's arguments, variables, child activities, and activity delegates.

Cancel(NativeActivityContext)

在衍生類別中實作時,執行邏輯以便在非失誤性的狀況下及早完成活動。When implemented in a derived class, runs logic to cause graceful early completion of the activity.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Execute(NativeActivityContext)

在衍生類別中實作時,執行活動的執行邏輯。When implemented in a derived class, runs the activity's execution logic.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnCreateDynamicUpdateMap(NativeActivityUpdateMapMetadata, Activity)

建立動態更新的對應時引發事件。Raises an event when creating a map for the dynamic update.

OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity)

建立動態更新的對應時引發事件。Raises an event when creating a map for the dynamic update.

ShouldSerializeDisplayName()

指出是否應序列化 DisplayName 屬性。Indicates whether the DisplayName property should be serialized.

(繼承來源 Activity)
ToString()

傳回包含 StringIdDisplayNameActivityReturns a String that contains the Id and DisplayName of the Activity.

(繼承來源 Activity)
UpdateInstance(NativeActivityUpdateContext)

更新 NativeActivity 的執行個體。Updates the instance of NativeActivity.

適用於