Using Context.Write to *Update* a Context Property Value

Originally posted by Nick Heppleston at:

This one has been done to death, but I am writing a moniker replacement pipeline component and noticed some interesting behaviour when looking to update Context Properties.

If you need to update an existing Context Property value, there is no Update() method defined in the IBaseMessageContext interface. However it is possible to write your new value which will perform an update. So use the following code to update the value in an existing Context Property:

private void WriteContextPropertyValue(IBaseMessage msg, string propName, string propNamespace, string propValue)
    message.Context.Write(propertyName, propertyNamespace, propertyValue);

Using the above code in an NUnit test, we can see that our original SOAP moniker is updated with the correct HTTP moniker with little more than a Context Property write.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s