Runtime Services in App.Config in WF

Link. October 12, 2006. Comments [0]. Posted in: WinFX | Workflow

In Windows Workflow Foundation, you have two different ways of adding runtime services to the Workflow Engine:

  • Through code, by using the AddService() method of the WorkflowRuntime class
  • Through the application configuration file, by adding an entry to the <services/> tag.

The latter is possible not only for the default services built into WF, like the SqlWorkflowPersistenceService, but also for your own ones; you just have to make sure you specify the correct type.

You might have noticed that some of the service take extra parameters on the configuration file. For example, for the SqlWorkflowPersistenceService entry you can configure parameters like the ConnectionString, IsTransactional and so on.

What may not be so obvious is that you can do the same thing for your own services and it's very easy! All you have to do is provide a constructor to your service class that takes a NameValueCollection as an argument; this collection will then have any named parameters that were included in the configuration entry. So, to keep in mind:

  1. Add your service to the configuration entry; each parameter is added as an attribute in the corresponding <add/> tag. For example: <add type="..." ConnectionString="...."/>
  2. Add alternate constructor to your service class with a NameValueCollection argument
  3. Extract named parameters from the NameValueCollection as needed to initialize your runtime service.


Comments are closed.

Syndicate

About

Tomas Restrepo is a software developer located in Colombia, South America. His interests include .NET, Connected Systems, PowerShell and lately dynamic programming languages. More...

tomasrestrepo @ twitter My Flickr photostream My saved links on delicious My Technorati Profile

email: tomas@winterdom.com
msn: tomasr@passport.com

View my profile on LinkedIn

MVP logo

Ads


Links

Categories

Statistics

Total Posts: 1024
This Year: 94
This Month: 1
This Week: 2
Comments: 795

Blogroll

Archive

Other

Copyright © 2002-2008, Tomas Restrepo.

Powered by: newtelligence dasBlog 2.1.8139.823

Sign In