如何在重新托管的 Workflow 4 Designer 中自定义活动?

发布于 2024-09-29 06:25:02 字数 501 浏览 2 评论 0原文

文章展示了如何在重新托管的工作流设计器中创建自定义活动(与工作流基础 4)。在该示例中,通过实现 IActivityTemplateFactory 接口并为 Delay 输入指定默认值来创建 MyDelayActivity

但是,是否也可以修改活动的输入? 例如,假设我想添加一个新的 StartProcess 活动,它接受一个字符串并运行该字符串指定的进程。我可以通过添加 InvokeMethod 活动,指定 Process.Start 作为方法并指定包含字符串作为参数的 Collection,使用本机活动来实现此功能。

我可以通过仅包含字符串输入的 StartProcess 框来简化所有这些吗?

This article shows how to create a custom activity in a rehosted Workflow designer (with Workflow Foundation 4). In that example, a MyDelayActivity is created by implementing the IActivityTemplateFactory interface, and specifying the default value to the Delay inputs.

However, is it possible to modify the inputs of the activity as well?
For example, let's say I want to add a new StartProcess activity which takes a string and run the process specified by the string. I can implement this with the native activities by adding a InvokeMethod activity, specifying Process.Start as the method and a Collection containing the string as the parameter.

Can I simplify all these by just having a StartProcess box with only a string input?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盛夏已如深秋| 2024-10-06 06:25:02

当然,只需创建活动来完成工作并添加 InArgument 属性来提供您需要的数据。当您将活动拖放到设计图面上时,您可以使用属性表来设置参数。或者,您可以创建一个活动设计器来在设计界面上执行相同的操作,例如 WriteLine 活动。

例子:

public sealed class MyWriteLine : CodeActivity
{
    public InArgument<string> Text { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        string text = context.GetValue(this.Text);
        Console.WriteLine(text);
    }
}

Sure, just create the activity to do the work and add InArgument properties to provide the data you need. When you drop the activity on the design surface you can use the property sheet to set the arguments. Alternatively you can create an activity designer to do the same on the design surface like for example the WriteLine activity.

Example:

public sealed class MyWriteLine : CodeActivity
{
    public InArgument<string> Text { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        string text = context.GetValue(this.Text);
        Console.WriteLine(text);
    }
}
樱娆 2024-10-06 06:25:02

其他信息,MSDN 网站上有两个非常有用的视频教程: 开发自定义活动< /a> 和活动设计者,我认为演讲者是同一个莫里斯作为接受的回答者:)

Additional information, there are two very helpful video tutorials in the MSDN website: Developing custom activities and Activity designers, and I assume the speaker is the same Maurice as the accepted answerer :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文