Ejemplo n.º 1
0
        /// <summary></summary>
        /// <returns></returns>
        public override string ToString()
        {
            /*
             * simpleselector<out SimpleSelector ss> =		(. ss = new SimpleSelector(); string psd = null; JinxBot.Controls.CSS.Attribute atb = null; SimpleSelector parent = ss; .)
             * (ident						(. ss.ElementName = t.val; .)
             | '*'						(. ss.ElementName = "*"; .)
             | ('#' ident				(. ss.ID = t.val; .)
             | '.' ident				(. ss.Class = t.val; .)
             | attrib<out atb>		(. ss.Attribute = atb; .)
             | pseudo<out psd>		(. ss.Pseudo = psd; .)
             | )
             | )
             | {							(. SimpleSelector child = new SimpleSelector(); .)
             | ('#' ident				(. child.ID = t.val; .)
             | '.' ident				(. child.Class = t.val; .)
             | attrib<out atb>		(. child.Attribute = atb; .)
             | pseudo<out psd>		(. child.Pseudo = psd; .)
             | )						(. parent.Child = child;
             |                      parent = child;
             |                  .)
             | }
             | .
             */
            System.Text.StringBuilder txt = new System.Text.StringBuilder();
            if (combinator.HasValue)
            {
                switch (combinator.Value)
                {
                case JinxBot.Controls.CSS.Combinator.PrecededImmediatelyBy: txt.Append(" + "); break;

                case JinxBot.Controls.CSS.Combinator.ChildOf: txt.Append(" > "); break;

                case JinxBot.Controls.CSS.Combinator.PrecededBy: txt.Append(" ~ "); break;
                }
            }
            if (elementname != null)
            {
                txt.Append(elementname);
            }
            if (id != null)
            {
                txt.AppendFormat("#{0}", id);
            }
            if (cls != null)
            {
                txt.AppendFormat(".{0}", cls);
            }
            if (pseudo != null)
            {
                txt.AppendFormat(":{0}", pseudo);
            }
            if (attribute != null)
            {
                txt.Append(attribute.ToString());
            }
            if (function != null)
            {
                txt.Append(function.ToString());
            }
            if (child != null)
            {
                if (child.ElementName != null)
                {
                    txt.Append(" ");
                }
                txt.Append(child.ToString());
            }
            return(txt.ToString());
        }