如何在不序列化的情况下执行ActivityBuilder?
假设我有一个像这样以编程方式创建的工作流,
ActivityBuilder<int> ab = new ActivityBuilder<int>();
ab.Name = "Add";
ab.Properties.Add(new DynamicActivityProperty {Name = "Operand1", Type = typeof (InArgument<int>)});
ab.Properties.Add(new DynamicActivityProperty {Name = "Operand2", Type = typeof (InArgument<int>)});
ab.Implementation = new Sequence
{
Activities =
{
new WriteLine
{
Text =
new VisualBasicValue<string>(
"Operand1.ToString() + \" + \" + Operand2.ToString()")
}
}
};
我知道执行它的一种方法是首先将 ActivityBuilder
对象序列化为 XAML
。接下来,使用 ActivityXamlServices
加载序列化的 XAML
。创建参数字典。使用 WorkflowInvoker
或 WorkflowApplication
执行它
有没有办法执行此工作流而不需要将活动生成器转换/序列化为 XAML?
WorkflowApplication 和 WorkflowInvoker 将 Activity 作为执行的输入。我可以以某种方式直接将 activityBuilder.Implementation
与 WorkflowApplication
或 WorkflowInvoker
结合使用吗?
为什么我想要这个?因为我们有一个工作流设计器,用户可以使用它来创建和执行工作流。用户还可以通过编程方式创建工作流程。工作流的大小最大可达 80MB。由于 80MB 文件与 XAML
之间的序列化和反序列化,这会损害应用程序的内存。我想以某种方式跳过这一步并直接执行活动。
有道理吗?
Let's say I have a workflow created progrmatically like this
ActivityBuilder<int> ab = new ActivityBuilder<int>();
ab.Name = "Add";
ab.Properties.Add(new DynamicActivityProperty {Name = "Operand1", Type = typeof (InArgument<int>)});
ab.Properties.Add(new DynamicActivityProperty {Name = "Operand2", Type = typeof (InArgument<int>)});
ab.Implementation = new Sequence
{
Activities =
{
new WriteLine
{
Text =
new VisualBasicValue<string>(
"Operand1.ToString() + \" + \" + Operand2.ToString()")
}
}
};
One way I know to execute it is to first serialize the ActivityBuilder
object into XAML
. Next, load the serialized XAML
using ActivityXamlServices
. Create a dictionary for parameters. Execute it using WorkflowInvoker
or WorkflowApplication
Is there any way to execute this workflow without the need to convert/serialize activity builder to XAML?
WorkflowApplication and WorkflowInvoker takes an Activity as input for execution. Can I somehow use activityBuilder.Implementation
directly with WorkflowApplication
or WorkflowInvoker
?
Why I want this? Because we have a workflow designer which user uses to create and execute workflow. User also creates workflow progrmatically. Workflow can be up to 80MB in size. This is hurting application's memory due to serialization and de-serialization of 80MB files to and from XAML
. I want to somehow skip this step and directly execute activity.
Does it makes sense?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无需使用 ActivityBuilder,只需创建所需的活动并执行它们即可。
使用 DynamicActivityProperty 的示例:
No need to use an ActivityBuilder, just create the activities you want and execute them.
An example using DynamicActivityProperty: