Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 public override void ApplyToHtmlFragment(HtmlFragment htmlFragment, string content)
 {
     htmlFragment.AddClass(CssClass);
 }
Exemplo n.º 5
0
 public abstract void ApplyToHtmlFragment(HtmlFragment htmlFragment, string content);