自定义活动中内联代码

发布于 2024-11-18 06:35:59 字数 216 浏览 4 评论 0原文

我想创建一个自定义活动,让创建 wf 定义的工程师可以编写一些小代码块,例如创建/转换数据结构,而无需为每个活动编写、编译和部署代码活动。

因此,我需要的是带有 ExpressionTextBox 多行或 CodeEditor(带有智能感知)的自定义活动来内联编写此代码,以便在自定义活动的 Execute 方法中执行。

您认为可能吗?

预先感谢,

马克

I would like to create a custom activity where our engineers, who creates the wf definitions, could write some small blocks of code like creating/converting data structures, without having to write, compile and deploy a code activity for each.

So, what I would need is something like a custom activity with an ExpressionTextBox multiline or a CodeEditor (with intellisense) to write this code inline in order to be executed in the Execute method of my custom activity.

Do you think it is possible?

Thanks in advance,

Marc

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

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

发布评论

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

评论(2

画▽骨i 2024-11-25 06:35:59

这可能吗?可能吧。

您必须提供体验的每个部分。这意味着,您必须提供一个自定义 Activity,该 Activity 可以配置为在运行时编译和执行的脚本、该 Activity 在 UI 中的代码编辑体验,以及某种类型的代码验证工具(报告错误)代码给用户。

对于编辑器,您可以使用 AvalonEdit,SharpDevelop 中的 WPF 代码编辑器。我以前没有使用过它,所以我无法告诉您需要做多少工作才能使智能感知和验证正常工作。

在运行时,您可以使用 CSharpCodeProvider 来编译代码,然后在运行时执行它。 Skeet 为他的 Snippy 应用程序执行了此操作,您可以在此处获取源代码。

所以您可以执行此操作。经过大量的工作和艰辛。

我认为更好的解决方案是提供许多小型活动,它们代表运行时编码体验的原子组件,可用于组装您期望用代码编写的逻辑。这更符合WF的精神。

Is this possible? Possibly.

You would have to provide for every part of the experience. That means, you would have to provide for a custom Activity that can be configured with a script to be compiled and executed at runtime, the code editing experience for this Activity in the UI, and some type of code validation facilities which reports errors in the code to the user.

For the editor, you could use AvalonEdit, the WPF code editor found in SharpDevelop. I haven't used it before, so I cannot tell you how much work you have to do in order to get intellisense and validation working.

At runtime, you can use the CSharpCodeProvider to compile the code and then execute it at runtime. Skeet does this for his Snippy app, you can get the source here.

So you can do this. After much work and hardship.

I think the better solution would be to provide a number of small Activities which represent atomic components of the coding experience at runtime, which can be used to assemble the logic that you are expecting to be written in code. This is more in the spirit of WF.

千笙结 2024-11-25 06:35:59

你不能这样做。在 Wf4 中,标记、XAML 和代码实现之间完全分离。

You can't do this. In Wf4 there is a complete separation between the markup, XAML, and the implementation, in code.

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