Monday, April 27, 2009

Today I was working with a pipeline component which encrypted fields in an XML message, for sensitive information. I realized that I needed to use it with a Flat File disassembler, which means that the original message was not XML, so I had to put my component after the Flat File disassembler. For various reasons, I wanted to use my component no later than the Dissasembler stage for this scenario.

So first, I added IDisassemblerComponent to the list of interfaces being implemented in my pipeline component class.

Then, I added the following code:


private bool beginMessage = false;
private IPipelineContext pContext;
private IBaseMessage pInMsg;

void IDisassemblerComponent.Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
{
beginMessage = true;
this.pContext = pContext;
this.pInMsg = pInMsg;
}

IBaseMessage IDisassemblerComponent.GetNext(IPipelineContext pContext)
{
if (beginMessage)
{
beginMessage = false;
return Execute(pContext, pInMsg);
}
else
{
return null;
}
}


This will only work if the previous disassembler is supposed to produce one message.




4/29/2010 - Changed the code to reflect changes suggested by Johan Rex...