开发者

Code inline in custom activities

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 e开发者_如何学运维xecuted in the Execute method of my custom activity.

Do you think it is possible?

Thanks in advance,

Marc


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜