从自定义活动访问参数、工作流程变量

发布于 2024-09-01 14:47:03 字数 175 浏览 4 评论 0原文

我有一个由许多自定义活动组成的工作流程。所有这些活动都需要访问工作流本身的启动参数。我可以在所有这些自定义活动中定义 InArgument 并将工作流参数绑定到自定义活动参数,但我对此解决方案不满意。从自定义活动访问工作流级别参数和变量声明的最佳方式是什么。我可以从 ActivityContext 获取它们吗?

谢谢。

I have a workflow composed of many custom activities. All these activities need to access startup arguments of the workflow itself. I can define InArgument inside all these custom activities and bind the workflow arguments to custom activity arguments but I am not comfortable with this solution. What is the best way to access workflow level argument and variable declarations from custom activities. Can I get them from ActivityContext?

Thanks.

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

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

发布评论

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

评论(1

岛徒 2024-09-08 14:47:03

我们通过自定义活动查看此问题的一种方法是使用 ActivityContext 中可用的 Properties 属性。我们有一个带有 InArgument 的活动,它在执行方法中添加了 ExecutionProperty,因此您最终会得到:

public InArgument<Custom> MyObject {get;set;}

...

context.Properties.Add("Contact",MyObject.Get(context));

然后在您的其他活动中,您可以检查是否已设置它

context.Properties.Find("Contact")

显然,如果您经常这样做,我建议在某处使用常量而不是魔术字符串,但这应该可以让您在设计时不必一遍又一遍地添加相同的参数。

One way we've looked at this with our custom activities is using the Properties property available in the ActivityContext. We have an activity with an InArgument which adds an ExecutionProperty in the execute method, so you end up with:

public InArgument<Custom> MyObject {get;set;}

...

context.Properties.Add("Contact",MyObject.Get(context));

Then in your other activities you can check to see if this has been set

context.Properties.Find("Contact")

Obviously if you're doing this a lot I'd recommend using a constant somewhere rather than magic strings, but it should save you having to add the same argument over and over when designing.

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