Edit

Share via


PersistenceParticipant Class

Definition

This class allows both WorkflowApplication and WorkflowServiceHost to participate in persistence process. A persistence participant derives from the PersistenceParticipant class or the PersistenceIOParticipant class (derived class of the PersistenceParticipant class), implements abstract methods, and then add an instance of the class as a workflow instance extension. The WorkflowApplication and WorkflowServiceHost look for such extensions when persisting an instance and invoke appropriate methods at appropriate times.

public ref class PersistenceParticipant abstract
public abstract class PersistenceParticipant
type PersistenceParticipant = class
Public MustInherit Class PersistenceParticipant
Inheritance
PersistenceParticipant
Derived

Examples

The following code sample demonstrates creating a class that derives from PersistenceParticipant. This example is from the Hiring Process sample.

public class HiringRequestInfoPersistenceParticipant: PersistenceIOParticipant
{
    public HiringRequestInfoPersistenceParticipant()
        : base(true, false)
    {
    }

Remarks

A host executes the following steps (or stages) when persisting an instance:

  1. Collects values to be persisted.

  2. Maps fields of monolithic structured values to individual values.

  3. Issues the SaveWorkflowCommand to the persistence provider.

  4. Performs I/O under the persistence transaction.

A host completes a stage before beginning the next stage. For example when persisting, the host collects values from all the persistence participants before moving to the second stage. In the second stage, the host provides all the values collected in the first stage to all persistence participants in the second stage for mapping. In the third stage, the host provides all the collected values in the first and second stages to the persistence provider when invoking the SaveWorkflowCommand. Then in the fourth stage, the host provides all the collected values to all the persistence IO participants under the persistence transaction.

A host executes the following stages when loading a persistence instance:

  1. Issues the LoadWorkflowCommand and LoadWorkflowByInstanceKeyCommand to the persistence provider.

  2. Performs I/O under the persistence transaction.

  3. Publishes the loaded values.

At the highest level, workflow instance extensions that derive from the PersistenceParticipant class can participate in the first (Collect) and second (Map) stages of persisting process and the third stage (Publish) of loading process. Workflow instance extensions deriving from the PersistenceIOParticipant class can additionally participate in the fourth stage of the persisting process and the second stage of the loading process (I/O).

Constructors

PersistenceParticipant()

Initializes an instance of the PersistenceParticipant class.

Methods

CollectValues(IDictionary<XName,Object>, IDictionary<XName,Object>)

A host invokes this method on a custom persistence participant to collect read-write values and write-only values, to be persisted.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MapValues(IDictionary<XName,Object>, IDictionary<XName,Object>)

A host invokes this method after it is done with collecting the values in the first stage. The host forwards two read-only dictionaries of values it collected from all persistence participants during the first stage (CollectValues stage) to this method for mapping. The host adds values in the dictionary returned by this method to the collection of write-only values.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
PublishValues(IDictionary<XName,Object>)

The host invokes this method and passes all the loaded values in the InstanceData collection (filled by the LoadWorkflowCommand or LoadWorkflowByInstanceKeyCommand) as a dictionary parameter.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to