Example #1
0
        public Td SerializeToTd(MemberInfo prop, object item)
        {
            var val = HtmlSupport.TryGetVal(prop, item);

            if (val is List <Linking> )
            {
                val = (val as List <Linking>).OfType <A>().ToList();
            }
            var element = _rootSerializer.Serialize(val, 2, _rootSerializer);

            return(element != null ? new Td {
                Subs = element.ToArray()
            } : new Td(val?.ToString()));
        }
Example #2
0
        public static IEnumerable <IHtmlElement> SerializeProps(object x, int lvl, IHtmlSerializer fac, IEnumerable <MemberInfo> props, bool includeType)
        {
            var itemType = HtmlSupport.Itemtype(x);

            var subs = new List <IHtmlElement>();

            if (includeType)
            {
                subs.AddRange(new IHtmlElement[]
                {
                    new Dt("Type"),
                    new Dd
                    {
                        Title = itemType,
                        Text  = x.GetType().Name,
                    },
                });
            }

            props
            .Select(mi => new { mi.Name, Val = HtmlSupport.TryGetVal(mi, x) })
            .Where(a => a.Val != null)
            .SelectMany(a => new IHtmlElement[]
            {
                new Dt(a.Name),
                new Dd {
                    Itemprop = PropName(a.Name), Subs = fac.Serialize(a.Val, lvl - 1, fac).ToArray()
                }
            })
            .ToList().ForEach(e => subs.Add(e));

            return(new Dl
            {
                Subs = subs.ToArray(),
                Itemscope = true,
                Itemtype = itemType,
            }.ToArray());
        }