public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { var contentReader = new ContentReader(); var data = pInMsg.BodyPart.GetOriginalDataStream(); if (!data.CanSeek || !data.CanRead) { const int bufferSize = 0x280; const int thresholdSize = 0x100000; data = new ReadOnlySeekableStream(data, new VirtualStream(bufferSize, thresholdSize), bufferSize); pContext.ResourceTracker.AddResource(data); } if (contentReader.IsXmlContent(data)) { var encoding = contentReader.Encoding(data); data = new XmlNamespaceRemover(data, encoding); pContext.ResourceTracker.AddResource(data); pInMsg.BodyPart.Data = data; } else { data.Seek(0, SeekOrigin.Begin); pInMsg.BodyPart.Data = data; } return(pInMsg); }
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { var contentReader = new ContentReader(); var data = pInMsg.BodyPart.GetOriginalDataStream(); if (!data.CanSeek || !data.CanRead) { const int bufferSize = 0x280; const int thresholdSize = 0x100000; data = new ReadOnlySeekableStream(data, new VirtualStream(bufferSize, thresholdSize), bufferSize); pContext.ResourceTracker.AddResource(data); } if (contentReader.IsXmlContent(data)) { var encoding = contentReader.Encoding(data); data = new ContentWriter().RemoveNamespace(data, encoding); pContext.ResourceTracker.AddResource(data); pInMsg.BodyPart.Data = data; } else { data.Seek(0, SeekOrigin.Begin); pInMsg.BodyPart.Data = data; } return pInMsg; }
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { string errorMessage; if (!Validate(out errorMessage)) { throw new ArgumentException(errorMessage); } var contentReader = new ContentReader(); var data = pInMsg.BodyPart.GetOriginalDataStream(); const int bufferSize = 0x280; const int thresholdSize = 0x100000; if (!data.CanSeek || !data.CanRead) { data = new ReadOnlySeekableStream(data, new VirtualStream(bufferSize, thresholdSize), bufferSize); pContext.ResourceTracker.AddResource(data); } if (contentReader.IsXmlContent(data) && contentReader.NamespacExists(data, NamespaceToModify)) { var encoding = contentReader.Encoding(data); data = new XmlNamespaceModifier(data, encoding, NewNamespace, null, NamespaceToModify); data = new ReadOnlySeekableStream(data, new VirtualStream(bufferSize, thresholdSize), bufferSize); pContext.ResourceTracker.AddResource(data); pInMsg.BodyPart.Data = data; if (ShouldUpdateMessageTypeContext) { var rootName = contentReader.GetRootNode(data); var contextReader = new ContextReader(); contextReader.UpdateMessageTypeContext(pInMsg.Context, NewNamespace, rootName); } } else { data.Seek(0, SeekOrigin.Begin); pInMsg.BodyPart.Data = data; } return(pInMsg); }
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { string errorMessage; if (!Validate(out errorMessage)) { throw new ArgumentException(errorMessage); } var contentReader = new ContentReader(); var data = pInMsg.BodyPart.GetOriginalDataStream(); if (!data.CanSeek || !data.CanRead) { const int bufferSize = 0x280; const int thresholdSize = 0x100000; data = new ReadOnlySeekableStream(data, new VirtualStream(bufferSize, thresholdSize), bufferSize); pContext.ResourceTracker.AddResource(data); } if (contentReader.IsXmlContent(data) && contentReader.NamespacExists(data, NamespaceToModify)) { var encoding = contentReader.Encoding(data); data = new ContentWriter().ModifyNamespace(data, NamespaceToModify, NewNamespace, encoding); pContext.ResourceTracker.AddResource(data); pInMsg.BodyPart.Data = data; if (ShouldUpdateMessageTypeContext) { var rootName = contentReader.GetRootNode(data); var contextReader = new ContextReader(); contextReader.UpdateMessageTypeContext(pInMsg.Context, NewNamespace, rootName); } } else { data.Seek(0, SeekOrigin.Begin); pInMsg.BodyPart.Data = data; } return pInMsg; }