Building Reusable Pipeline Components Part 2: Static Message Context Component

A Static Message Context is a Pipeline Component that has one or more Context Properties configured and applies them to each message that travels through the Pipeline.


The following class diagram shows the classes of the Static Message Context component:


Static Message Context classes


The StaticMessageContext class derives from PipelineComponentWithResourceBase base class and passes a name prefix and an instance to a ResourceManager in its constructor. The class also overrides the ExecuteInternal method to apply the configured Context Properties to the message being processed. Applying the configured properties is simply a matter of iterating over the configured properties and writing or promoting them to the message context of the current message being processed.


Both the Load and the Save methods are overridden to manage the configured properties persistence. Four values per configured property are maintained (Key, Namespace, Value and Promote) and an extra count value to indicate the number of configured properties. The StaticMessageContextBagNames utility class manages the names for each configured property in the persistence bag.


Download the source code here.