views:

288

answers:

4

Hello,

I'm currently charged of developing a way to use WF in our application and I have a set requirements that I need to follow.

  • I need to be able to define the workflow purely on text so I can store it and retrieve it for execution.
  • During the workflow execution a DataObject needs to be passed between the activities so they can perform operation on it.
  • The activities are defined by external classes, the activities need to access an instance of the class that defines them so they can call its methods.

I've been studying WF and I came up with some solutions but I'm not sure if they are the best ones.

One of my biggest problems is to make available to the activities an instace of the classes that define them. Is there a way to provide to the workflow runtime an activity factory or something like that? Another problem comes from using Pure XAML workflow definitions. I need to be able to pass the DataObject to the first activiy so it can be used in the workflow.

I have some difficulty explaining the problem, I hope its clear enough.

Any help will be appreciated. Thanks.

+1  A: 

In relation to providing external activities to the runtime that are used within the context of a XOML workflow, take a look at adding a TypeProvider service to your runtime:

TypeProvider provider = new TypeProvider(runtime);
provider.AddAssembly(assembly);
runtime.AddService(provider);

Also, look at defining a root activity that has a DependencyProperty that is of your DataObject type. Make the root activity of your XOML based workflows of that base type. You should then be able to pass your object into the XOML based worflows as a parameter without any problems.

MattK
I don't think the TypeProvider solves my problem. Please refer to my answer in the post. Tks.
Megacan
A: 

I've been looking at TypeProvider but it seems like I can only add new locations for activities. However the runtime will continue to instantiate the activities himself. I wanted to be able to instantiate them so I could pass some arguments to the contructor.

I solved the DataObject problem pretty much the way you described.

Megacan
+1  A: 

I'm not quite sure I fully understand what you want to do, but you may want to look at a custom loader:

http://msdn.microsoft.com/en-us/magazine/cc507645.aspx

http://www.masteringbiztalk.com/blogs/jon/CommentView,guid,ffd20921-fb8b-42a2-98d1-8c8e1582a3fa.aspx

MattK
A: 

I think the WorkflowLoaderService is the class I was looking for.

That should do it. Thanks.

Megacan