PersistenceParticipant
I am looking at WF 4.0 lately and I found out that there is no clear documentation on PersistenceParticipants.
Well The idea is simple:
If you want to add some state to your workflow persistence data or in other words save some more data with your workflow, you can use a PersistenceParticipant.
The PersistenceParticipant is a class that holds your data but also implements IPersistenceParticipant interface. This interface makes it possible to load and unload the data.
PersistenceParticipant is a great extensibility point with which you can hook extra work to the persistence events.
The PersistenceParticipant has to be bound to the workflow instance using:
void IActivityExtensionProvider.EnsureExtensions(IExtensionHost host)
{
if (host.GetExtension<StepCountExtension>() == null)
{
host.Extensions.Add(new YourPersistenceParticipant ());
}
}
To get hold of the participant from inside or outside the workflow use: the GetExtension<YourPersistenceParticipant>() method of the workflow instance or the CodeActivityContext.
There is a great example in the wf_wcf 4.0 samples