将参数绑定到 Windows Workflow 实例& 忽略未使用的

发布于 2024-07-15 23:47:15 字数 433 浏览 3 评论 0原文

我在 Dictionary 中有一堆命名值参数,我想将它们传递到不同的工作流程中。 问题是每个工作流程只需要字典中属性的子集,并且我事先不知道哪个工作流程需要哪些属性。

问题是,当我使用要绑定的字典调用 WorkflowRuntime.CreateWorkflow 时,它失败并显示:

The activity '<workflow name>' has no public writable property named '<property name>'

我知道这意味着什么。 工作流中的属性未定义,因为此特定工作流不需要该特定属性(其他工作流可能)。

无论如何,是否可以将字典绑定到工作流属性,并忽略工作流中未定义的属性?

I have a bunch of named value parameters in a Dictionary<string, object>, which I want to pass into different workflows. The catch is that each workflow will only need a subset of the properties in the dictionary, and I don't know beforehand which workflow needs which properties.

The problem is that when I call WorkflowRuntime.CreateWorkflow with the dictionary to bind with, it fails with:

The activity '<workflow name>' has no public writable property named '<property name>'

I know what this means. The property in the workflow is not defined because this particular workflow does not need that particular property (other workflows might).

Is there anyway to bind a dictionary to workflow properties, and IGNORE properties that are not defined on the workflow?

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

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

发布评论

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

评论(1

绝情姑娘 2024-07-22 23:47:15

为什么不将字典传递到工作流程实例中? 然后,您的工作流程定义只需具有该字典的属性即可。

var inputs = Dictionary<string, YOUR_CUSTOM_TYPE>();
// ...
// fill your dictionary according to the context
// ...
var inputParams = new Dictionary<string, object>();
inputParams["WF_PROP_NAME"] = inputs;
var wfInstance = wfRuntime.CreateWorkflow(WF_TYPE, inputParams);

这样,您的工作流程只需从字典中获取感兴趣的字典项目。

Why don't you pass your dictionary into the workflow instances? Your workflow definitions then just have to have a property for that dictionary.

var inputs = Dictionary<string, YOUR_CUSTOM_TYPE>();
// ...
// fill your dictionary according to the context
// ...
var inputParams = new Dictionary<string, object>();
inputParams["WF_PROP_NAME"] = inputs;
var wfInstance = wfRuntime.CreateWorkflow(WF_TYPE, inputParams);

This way your workflows just get the dictionary items of interest from the dictionary.

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