Originally posted by Nick Heppleston at: http://www.modhul.com/2009/03/05/using-contextwrite-to-update-a-context-property-value/
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.

0 Responses to “Using Context.Write to *Update* a Context Property Value”