public override XDoc AsEmbeddableXml(bool safe) { MimeType mime = (Value.Segments.Length > 0) ? MimeType.FromFileExtension(Value.LastSegment ?? string.Empty) : MimeType.BINARY; if (StringUtil.EqualsInvariant(mime.MainType, "image")) { // embed <img> tag return(DekiScriptLibrary.WebImage(AsString(), null, null, null)); } else { // embed <a> tag return(DekiScriptLibrary.WebLink(AsString(), null, null, null)); } }
private void AddUri(XmlNode context, DekiScriptUri uri) { if (context == null) { ConvertStateToHtml(null); } // NOTE (steveb): URIs have special embedding rules; either embed it as a <img> and <a> document base on the URI file extension on the last segment XUri url = uri.Value.AsPublicUri(); MimeType mime = (url.Segments.Length > 0) ? MimeType.FromFileExtension(url.LastSegment ?? string.Empty) : MimeType.BINARY; XDoc item = mime.MainType.EqualsInvariant("image") ? DekiScriptLibrary.WebImage(url.ToString(), null, null, null) : DekiScriptLibrary.WebLink(url.ToString(), null, null, null); AddXDoc(context, item); }