private HtmlFragment createHtmlFragment(Fragment fragment) { var htmlFragment = new HtmlFragment(); var transformers = from tag in fragment.Tags select _transformerPool.GetByTag(tag); var contentHandlingType = applyTransformers(transformers, fragment.Text, htmlFragment); if (contentHandlingType == ContentHandlingType.Automatic) { htmlFragment.InnerText = fragment.Text; } return htmlFragment; }
public override void ApplyToHtmlFragment(HtmlFragment htmlFragment, string content) { if (!htmlFragment.IsHtmlTagNameDefined) { htmlFragment.AddClass(CssClass); htmlFragment.HtmlTag = "img"; htmlFragment.Attributes += string.Format(" src=\"{0}\" ", content); } else { htmlFragment.InnerText += string.Format("<img src=\"{0}\" class=\"{1}\" />", content, CssClass); } }
private ContentHandlingType applyTransformers(IEnumerable<Transformer> transformers, string fragmentText, HtmlFragment htmlFragment) { var contentHandlingType = ContentHandlingType.Automatic; foreach (var transformer in transformers) { transformer.ApplyToHtmlFragment(htmlFragment, fragmentText); if (transformer.HandlesContent) { if (contentHandlingType == ContentHandlingType.Transformer) { throw new TransformerContentHandlingConflict(transformer.ToString()); } contentHandlingType = ContentHandlingType.Transformer; } } return contentHandlingType; }
public override void ApplyToHtmlFragment(HtmlFragment htmlFragment, string content) { htmlFragment.AddClass(CssClass); }
public abstract void ApplyToHtmlFragment(HtmlFragment htmlFragment, string content);