public void Convert(HtmlNode node, XmlWriter writer) { var classOfNode = node.GetAttributeValue("class", string.Empty); var nodeLink = node.GetAttributeValue("href", string.Empty); string internalUrl; if (Helpers.TryResolveInternalLink(nodeLink, out internalUrl)) { nodeLink = internalUrl; } AssetLinkBase link = null; if (classOfNode.Equals("enlarge", StringComparison.CurrentCultureIgnoreCase)) { var content = new InnerTextNode(); content.Convert(node, writer); return; } if (SupportingDocumentLink.IsSupportedExtension(nodeLink)) { link = new SupportingDocumentLink(); } else if (!string.IsNullOrEmpty(nodeLink)) { link = new ExternalLink(); } if (link != null) { using (var ms = new MemoryStream()) { using (var sw = new StreamWriter(ms)) { link.Write(sw, nodeLink, node.InnerText); } var bytes = ms.ToArray(); var value = Encoding.UTF8.GetString(bytes); writer.WriteString(value); } } else { // render the inside of an element. var content = new InnerTextNode(); content.Convert(node, writer); } }
public static string FromId(string linkType, string linkId, string linkName) { if (!AssetLinkMappings.ContainsKey(linkType)) { return(string.Empty); } AssetLinkBase link = AssetLinkMappings[linkType]; using (var ms = new MemoryStream()) { using (var sw = new StreamWriter(ms)) { link.Write(sw, linkId); sw.Flush(); } var bytes = ms.ToArray(); return(Encoding.UTF8.GetString(bytes)); } }