Ejemplo n.º 1
0
        static IChain <T> MergeCssAttributes <T> (this IChain <T> chain) where T : HAttribute, new()
        {
            if (!chain.ToEnumerable().Any(a => a.Name == "class"))
            {
                return(chain);
            }

            var combinedCss  = MergeCss(chain.ToEnumerable().Where(a => a.Name == "class" && a.Value != null).Select(a => "" + a.Value).ToList());
            var cssAttribute = (T) new T().Create("class", combinedCss);

            return(new Chain <T> (chain.ToEnumerable().Where(a => a.Name != "class").Concat(new T[] { cssAttribute })));
        }
Ejemplo n.º 2
0
        public HElement(string name, IChain <HAttribute> attributes, IEnumerable <object> children) : base(children)
        {
            this.Name = name;

            if (attributes != null)
            {
                Attributes = attributes.ToEnumerable().Where(a => a.Value != null).ToList();
            }

            Validate();
        }
Ejemplo n.º 3
0
 public static IChain <T> Join <T> (this IChain <T> x, IChain <T> y)
 {
     if (x == null && y == null)
     {
         return(new Chain <T> (null));
     }
     if (x == null)
     {
         return(y);
     }
     if (y == null)
     {
         return(x);
     }
     return(new Chain <T> (x.ToEnumerable().Concat(y.ToEnumerable())));
 }
Ejemplo n.º 4
0
        public HElement(string name, IChain<HAttribute> attributes, IEnumerable<object> children)
            : base(children)
        {
            this.Name = name;

            if (attributes != null)
                Attributes = attributes.ToEnumerable ().Where (a => a.Value != null).ToList ();

            Validate ();
        }