private string GetConfirmationText(PriceHedgePage currentPage, string agreement) { if (string.IsNullOrEmpty(agreement)) { return(string.Empty); } XhtmlString confirmationXhtml = null; if (agreement.Equals(AgreementType.Depaavtal)) { confirmationXhtml = currentPage.ConfirmationTextForDepaavtal; } else if (agreement.Equals(AgreementType.Poolavtal)) { confirmationXhtml = currentPage.ConfirmationTextForPoolavtal; } else if (agreement.Equals(AgreementType.SportAndForwardAvtal)) { confirmationXhtml = currentPage.ConfirmationTextForSportavtal; } else if (agreement.Equals(AgreementType.PrissakringDepaavtal)) { confirmationXhtml = currentPage.ConfirmationTextForPrissakringDepaavtal; } return(confirmationXhtml?.ToString() ?? string.Empty); }
public static XhtmlString StripTags(this XhtmlString self, params string[] tags) { if (self == null) { return(null); } var pattern = string.Format("</?(?:{0})( [^>]+)?>", string.Join("|", tags)); return(new XhtmlString(Regex.Replace(self.ToString(), pattern, "", RegexOptions.IgnoreCase))); }
private bool ValidateXhtmlString(XhtmlString xhtml) { if (xhtml == null || xhtml.IsEmpty) { return(true); } var doc = new HtmlDocument(); doc.LoadHtml(xhtml.ToString()); // if there are images without alt tags, invalid IEnumerable <HtmlNode> imgs = doc.DocumentNode.Descendants("img"); if (imgs != null && imgs.Any()) { if (imgs.Any(i => i.Attributes["alt"] == null || string.IsNullOrWhiteSpace(i.Attributes["alt"].Value))) { return(false); } } return(true); }