NativeActivity<TResult> Class

Definition

适用于特定自定义活动(这些活动使用 Execute(NativeActivityContext) 方法实现执行逻辑,该方法具有对运行时功能的完全访问权限)的抽象基类。Abstract base class for custom activities that implement execution logic using the Execute(NativeActivityContext) method, that has full access to the runtime's features.

generic <typename TResult>
public ref class NativeActivity abstract : System::Activities::Activity<TResult>
public abstract class NativeActivity<TResult> : System.Activities.Activity<TResult>
type NativeActivity<'Result> = class
    inherit Activity<'Result>
Public MustInherit Class NativeActivity(Of TResult)
Inherits Activity(Of TResult)

Type Parameters

TResult

活动返回的结果。The result returned by the activity.

Inheritance
Derived

Examples

下面的代码示例演示如何创建一个从 NativeActivity<TResult> 继承的类。The following code sample demonstrates creating a class that inherits from NativeActivity<TResult>. 此示例来自如何:创建入门教程 [ ] .NET Framework 4.5的活动步骤。This example is from the How to: Create an Activity step of the Getting Started Tutorial [.NET Framework 4.5].

public sealed class ReadInt : NativeActivity<int>
{
    [RequiredArgument]
    public InArgument<string> BookmarkName { get; set; }

    protected override void Execute(NativeActivityContext context)
    {
        string name = BookmarkName.Get(context);

        if (string.IsNullOrEmpty(name))
        {
            throw new ArgumentException("BookmarkName cannot be an Empty string.",
                "BookmarkName");
        }

        context.CreateBookmark(name, new BookmarkCallback(OnReadComplete));
    }

    // NativeActivity derived activities that do asynchronous operations by calling
    // one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext
    // must override the CanInduceIdle property and return true.
    protected override bool CanInduceIdle
    {
        get { return true; }
    }

    void OnReadComplete(NativeActivityContext context, Bookmark bookmark, object state)
    {
        this.Result.Set(context, Convert.ToInt32(state));
    }
}
Public NotInheritable Class ReadInt
    Inherits NativeActivity(Of Integer)
    
    <RequiredArgument()>
    Property BookmarkName() As InArgument(Of String)

    Protected Overrides Sub Execute(ByVal context As NativeActivityContext)
        Dim name As String
        name = BookmarkName.Get(context)

        If name = String.Empty Then
            Throw New ArgumentException("BookmarkName cannot be an Empty string.",
                "BookmarkName")
        End If

        context.CreateBookmark(name, New BookmarkCallback(AddressOf OnReadComplete))
    End Sub

    ' NativeActivity derived activities that do asynchronous operations by calling 
    ' one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext 
    ' must override the CanInduceIdle property and return True.
    Protected Overrides ReadOnly Property CanInduceIdle As Boolean
        Get
            Return True
        End Get
    End Property

    Sub OnReadComplete(ByVal context As NativeActivityContext, ByVal bookmark As Bookmark, ByVal state As Object)
        Result.Set(context, Convert.ToInt32(state))
    End Sub

End Class

Constructors

NativeActivity<TResult>()

在派生类中实现时,创建派生类的新实例。When implemented in a derived class, creates a new instance of the derived class.

Properties

CacheId

获取缓存的标识符,该标识符在工作流定义的作用域内是唯一的。Gets the identifier of the cache that is unique within the scope of the workflow definition.

(Inherited from 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.

(Inherited from Activity)
DisplayName

获取或设置用于调试、验证、异常处理和跟踪的可选友好名称。Gets or sets an optional friendly name that is used for debugging, validation, exception handling, and tracking.

(Inherited from Activity)
Id

获取一个标识符,该标识符在工作流定义的作用域内是唯一的。Gets an identifier that is unique in the scope of the workflow definition.

(Inherited from Activity)
Implementation

活动的执行逻辑。The execution logic of the activity.

ImplementationVersion

获取或设置活动的实现版本。Gets or sets the implementation version of the activity.

ImplementationVersion

获取或设置用于实现的版本。Gets or sets the version of the implementation used.

(Inherited from Activity)
Result

获取或设置 Activity<TResult> 的结果自变量。Gets or sets the result argument for the Activity<TResult>.

(Inherited from Activity<TResult>)
ResultType

在派生类中实现时,获取 OutArgument 活动的类型。When implemented in a derived class, gets the type of an activity OutArgument.

(Inherited from ActivityWithResult)

Methods

Abort(NativeActivityAbortContext)

在派生类中实现时,采取措施响应要放弃的活动。When implemented in a derived class, takes actions in response to the activity being aborted.

CacheMetadata(ActivityMetadata)

未实现。Not implemented. 请改用 CacheMetadata(NativeActivityMetadata)Use CacheMetadata(NativeActivityMetadata) 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.

(Inherited from Object)
Execute(NativeActivityContext)

在派生类中实现时,运行活动的执行逻辑。When implemented in a derived class, runs the activity's execution logic.

GetHashCode()

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

(Inherited from Object)
GetType()

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

(Inherited from Object)
MemberwiseClone()

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

(Inherited from 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.

OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity)

创建动态更新映射时引发事件。Raises an event when creating dynamic update map.

(Inherited from Activity)
ShouldSerializeDisplayName()

指示是否应序列化 DisplayName 属性。Indicates whether the DisplayName property should be serialized.

(Inherited from Activity)
ToString()

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

(Inherited from Activity)
UpdateInstance(NativeActivityUpdateContext)

更新 NativeActivity<TResult> 的该实例。Updates the instance of NativeActivity<TResult>.

Applies to