开发者

How can a WF4 Custom Activity determine that its in design mode v. executing mode

I have a WF4 custom activity with a custom designer (WPF). I would like to have slightly different behaviou开发者_如何学Cr in the CacheMetaData override depending on if the Activity is in Design or Execution mode.

Edit: Reasons for requirement. We have validation that needs to look up the data from the web.config file (or one of its includes). At run time we can use System.Configuration.ConfigurationManager, and at design time I need to use EnvDte to interrogate the project structure.

Since the Activity can be debugged, it could in be VS in either case so I cannot check for that.

Is there a service within WF4 I can call to tell what mode I'm in please?


As far as I know there is no good way of doing so.

You can check using the process name. If it is devenv you are in Visual Studio (if you are debugging it will be your project name with .vshost tagged on. But as the designer can be re hosted that is far from reliable.


One thing you could do is to actually have a separate design time activity from your runtime activity. This is what I'm doing. Takes a bit of work and might be overkill for your needs. Check out this WF forum post for more details.


If the reason for this requirement is purely validation couldn't you move the validation logic requiring EnvDTE to the designer component, leaving just the runtime validation logic in the activity itself?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜