private XElement ParseElement(IList <byte> document, int next) { if (next == 0) { currentPage = GetCurrentToken(document); next = GetCurrentToken(document); } var codePage = codePageProvider.GetCodePage(currentPage) + ":"; var hasContent = (next & 0x40) == 0x40; var currentToken = next & 0x3f; var element = new XElement((XNamespace)codePage + codePageProvider.GetToken(currentPage, currentToken)); if (hasContent) { while ((next = GetCurrentToken(document)) != 1) { //If value == 3 it marks the start of a string if (next == 3) { element.Value = GetString(document); } //If value == 0xC3 it marks the start of an opaque blob else if (next == 195) { element.Value = GetBlob(document); } else { element.Add(ParseElement(document, next)); } } } return(element); }
private IList <byte> GetElement(XElement element) { var result = new List <byte>(); var codePage = codePageProvider.GetCodePage(element.Name.Namespace.NamespaceName); result.AddRange(GetCodePage(codePage)); result.AddRange(GetContent(element)); result.AddRange(GetClosing()); return(result); }