/// <summary> /// Removes the byte order mask. /// </summary> /// <param name="inStream">Input stream.</param> /// <returns>New stream without the byte order mask.</returns> public static Stream RemoveByteOrderMark(Stream inStream) { if (inStream == null) { throw new ArgumentNullException("inStream"); } int num = MatchByteOrderMarkSequence(inStream); if (num <= 0) { return(inStream); } VirtualStream virtualStream = new VirtualStream((int)inStream.Length); byte[] buffer = new byte[BUFFER_SIZE]; inStream.Position = (long)num; int count; while ((count = inStream.Read(buffer, 0, BUFFER_SIZE)) > 0) { virtualStream.Write(buffer, 0, count); } virtualStream.Flush(); virtualStream.Position = 0L; return(virtualStream); }
public override void Flush() { if (HelperStream != null) { FlxMessages.ThrowException(FlxErr.ErrInternal); } VirtualStream.Flush(); }
public Microsoft.BizTalk.Message.Interop.IBaseMessage ExecuteThree(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg) { IBaseMessagePart bodyPart = pInMsg.BodyPart; Stream inboundStream = bodyPart.GetOriginalDataStream(); VirtualStream virtualStream = new VirtualStream(0x280, 0x100000); ReadOnlySeekableStream readOnlySeekableStream = new ReadOnlySeekableStream(inboundStream, virtualStream, 0x280); XmlTextReader xmlTextReader = new XmlTextReader(readOnlySeekableStream); //XPathCollection xPathCollection = new XPathCollection(); //xPathCollection.Add("/*[local-name()='LFT' and namespace-uri()='http://Codit.LFT.Schemas']/*[local-name()='TempFile' and namespace-uri()='']"); //XPathReader xPathReader = new XPathReader(xmlTextReader, xPathCollection); bool ok = false; string val = string.Empty; //while (xPathReader.ReadUntilMatch()) //{ // if (xPathReader.Match(0) && !ok) // { // val = xPathReader.ReadString(); // ok = true; // } //} if (ok) { VirtualStream outboundStream = new VirtualStream(0x280, 0xA00000); using (FileStream fs = new FileStream(val, FileMode.Open, FileAccess.Read, FileShare.Read)) { byte[] buffer = new byte[4096]; int bytesRead = fs.Read(buffer, 0, buffer.Length); while (bytesRead != 0) { outboundStream.Write(buffer, 0, bytesRead); outboundStream.Flush(); bytesRead = fs.Read(buffer, 0, buffer.Length); } } outboundStream.Position = 0; bodyPart.Data = outboundStream; } return(pInMsg); }
public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg) { IBaseMessagePart bodyPart = pInMsg.BodyPart; Stream inboundStream = bodyPart.GetOriginalDataStream(); VirtualStream virtualStream = new VirtualStream(0x280, 0x100000); ReadOnlySeekableStream readOnlySeekableStream = new ReadOnlySeekableStream(inboundStream, virtualStream, 0x280); XmlTextReader xmlTextReader = new XmlTextReader(readOnlySeekableStream); XPathCollection xPathCollection = new XPathCollection(); xPathCollection.Add("/*[local-name()='LFT' and namespace-uri()='http://Codit.LFT.Schemas']/*[local-name()='TempFile' and namespace-uri()='']"); XPathReader xPathReader = new XPathReader(xmlTextReader, xPathCollection); bool ok = false; string val = string.Empty; while (xPathReader.ReadUntilMatch()) { if (xPathReader.Match(0) && !ok) { val = xPathReader.ReadString(); ok = true; } } if (ok) { VirtualStream outboundStream = new VirtualStream(0x280, 0xA00000); using (FileStream fs = new FileStream(val, FileMode.Open, FileAccess.Read, FileShare.Read)) { byte[] buffer = new byte[4096]; int bytesRead = fs.Read(buffer, 0, buffer.Length); while (bytesRead != 0) { outboundStream.Write(buffer, 0, bytesRead); outboundStream.Flush(); bytesRead = fs.Read(buffer, 0, buffer.Length); } } outboundStream.Position = 0; bodyPart.Data = outboundStream; } return pInMsg; }