/// <summary></summary> /// <returns></returns> public override string ToString() { /* * term<out Term trm> = (. trm = new Term(); * string val = ""; * Function func = null; * .) * [ ('-' (. trm.Sign = '-'; .) | '+' (. trm.Sign = '+'; .) | ) ] | ( | { digit (. val += t.val; .) | } | [ ( | "%" (. trm.Unit = Unit.Percent; .) | "ex" (. trm.Unit = Unit.EX; .) | "em" (. trm.Unit = Unit.EM; .) | "px" (. trm.Unit = Unit.PX; .) | "cm" (. trm.Unit = Unit.CM; .) | "mm" (. trm.Unit = Unit.MM; .) | "pc" (. trm.Unit = Unit.PC; .) | "in" (. trm.Unit = Unit.IN; .) | "pt" (. trm.Unit = Unit.PT; .) | "deg" (. trm.Unit = Unit.DEG; .) | ["g" (. trm.Unit = Unit.GRAD; .) | ] "rad" (. if (trm.Unit != Unit.GRAD) { trm.Unit = Unit.RAD; } .) | ["m" (. trm.Unit = Unit.MS; .) | ] "s" (. if (trm.Unit != Unit.MS) { trm.Unit = Unit.S; } .) | ["k" (. trm.Unit = Unit.KHZ; .) | ] "hz" (. if (trm.Unit != Unit.KHZ) { trm.Unit = Unit.HZ; } .) | ) ] (. trm.Value = val; trm.Type = TermType.Number; .) | | function<out func> (. trm.Function = func; trm.Type = TermType.Function; .) | | QuotedString<out val> (. trm.Value = val; trm.Type = TermType.String; .) | | ident (. trm.Value = t.val; trm.Type = TermType.String; .) | | URI<out val> (. trm.Value = val; trm.Type = TermType.Url; .) | | "U\\" | { (digit|'A'|'B'|'C'|'D'|'E'|'F'|'a'|'b'|'c'|'d'|'e'|'f') | (. val += t.val; .) | } (. trm.Value = val; trm.Type = TermType.Unicode; .) | | hexdigit (. trm.Value = t.val; trm.Type = TermType.Hex; .) | ) | . */ System.Text.StringBuilder txt = new System.Text.StringBuilder(); //if (seperator.HasValue) { txt.Append(seperator.Value); txt.Append(" "); } if (type == TermType.Function) { txt.Append(function.ToString()); } else if (type == TermType.Url) { txt.AppendFormat("url('{0}')", val); } else if (type == TermType.Unicode) { txt.AppendFormat("U\\{0}", val.ToUpper()); } else if (type == TermType.Hex) { txt.Append(val.ToUpper()); } else { if (sign.HasValue) { txt.Append(sign.Value); } txt.Append(val); if (unit.HasValue) { if (unit.Value == breinstormin.tools.web.css.Model.Unit.Percent) { txt.Append("%"); } else { txt.Append(UnitOutput.ToString(unit.Value)); } } } return(txt.ToString()); }
/// <summary></summary> /// <returns></returns> public override string ToString() { /* * simpleselector<out SimpleSelector ss> = (. ss = new SimpleSelector(); string psd = null; breinstormin.tools.web.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 breinstormin.tools.web.css.Model.Combinator.PrecededImmediatelyBy: txt.Append(" + "); break; case breinstormin.tools.web.css.Model.Combinator.ChildOf: txt.Append(" > "); break; case breinstormin.tools.web.css.Model.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()); }