Windows Workflow Foundation 4 创建基本活动
在 Windows Workflow Foundation 3.x 中,您过去能够创建一个 BaseWorkflow 类,您可以在其中在该工作流程中定义一些属性。
然后,当您创建工作流时,您可以说它派生自 BaseWorkflow 类,因此它继承了基本工作流的所有属性。
我们能否在 Windows Workflow Foundation 4 (WF 4) 中实现同样的目标?就像在 BaseActivity 上定义 InArgument 和 OutArgument 一样,然后创建另一个从 BaseActivity 派生的 Activity。
我尝试修改 XAML,比如
WF 4 好像不行。
In Windows Workflow Foundation 3.x, you used to be able to create a BaseWorkflow class where you could define some properties in that workflow.
And then when you create a workflow you can say it derives from BaseWorkflow class so it inherits all the properties from the base workflow.
Can we achieve the same thing in Windows Workflow Foundation 4 (WF 4)? Like defining InArgument and OutArgument on a BaseActivity then create another Activity that derives from the BaseActivity.
I tried by modify the XAML from let's say <Activity></Activity> to like <BaseActivity></BaseActivity> ... that was the way we did it in WF 3.x.
It doesn't seem to work in WF 4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到了解决这个问题的办法。这实际上很容易。 XAML 声明生成的类被标记为
partial
,因此您可以为您的活动(工作流)基础创建一个类(也标记为partial
)。然后在 XAML 中,只需将 Activity 上的类属性更改为刚刚创建的类的完整命名空间即可。基活动示例:
XAML 示例:
使用此方法,您可以在基类上定义 in 和 out 参数,并且它们也会显示在您的派生活动中。
Found a solution to this. It's actually quite easy. The class generated by the XAML declaration is marked as
partial
so you can create a class (also markedpartial
) for your activity (workflow) base. Then in XAML, just change the class attribute on your activity to the full namespace of the class you just created.Base Activity Example:
XAML example:
With this method, you can define both in and out arguments on the base class and they show up for your derived activities as well.
是的,您可以创建一个
BaseActivity
并定义其 InArguments 和 OutArguments。然后,您可以创建一个新类,例如Activity1:BaseActivity
,它仍然具有BaseActivity
的 InArguments 和 OutArgumentsYes, you can create a
BaseActivity
and define its InArguments and OutArguments. You can then create a new class, sayActivity1:BaseActivity
and it still hasBaseActivity
's InArguments and OutArguments