Included epub library in plugin project

This commit is contained in:
Marco Gavelli
2018-07-16 10:06:17 +02:00
parent a78428c698
commit a82cacd126
57 changed files with 57 additions and 61 deletions

View File

@@ -0,0 +1,28 @@
using System.IO;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
namespace VersOne.Epub.Internal
{
internal static class XmlUtils
{
public static async Task<XDocument> LoadDocumentAsync(Stream stream)
{
using (MemoryStream memoryStream = new MemoryStream())
{
await stream.CopyToAsync(memoryStream).ConfigureAwait(false);
memoryStream.Position = 0;
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
{
DtdProcessing = DtdProcessing.Ignore,
Async = true
};
using (XmlReader xmlReader = XmlReader.Create(memoryStream, xmlReaderSettings))
{
return await Task.Run(() => XDocument.Load(memoryStream)).ConfigureAwait(false);
}
}
}
}
}