/// <summary> /// Wraps payload + headers into a StandardBusinessDocument /// </summary> /// <param name="inputStream">the input stream to be wrapped</param> /// <param name="headers">the headers to use for sbdh</param> /// <returns>byte buffer with the resulting output in utf-8</returns> public byte[] Wrap(Stream inputStream, Header headers) { MemoryStream m = new MemoryStream(); try { using (SbdWriter sbdWriter = SbdWriter.NewInstance(m, headers)) { sbdWriter.AddFragment(inputStream); } } catch (Exception ex) { throw new InvalidOperationException("Unable to wrap document inside SBD (SBDH). " + ex.Message, ex); } return(m.ToBuffer()); }
public Stream Wrap(Stream inputStream, Header header) { var m = new MemoryStream(); try { var xml = new XmlTextWriter(m, Encoding.UTF8); xml.Formatting = Formatting.None; using (SbdWriter.NewInstance(m, header)) { XmlTools.AddXmlFragment(inputStream, xml); } } catch (Exception e) { throw new HyperwayContentException("Unable to wrap content into SBDH.", e); } m.Seek(0, SeekOrigin.Begin); return(m); }