|
using System;
using System.Xml.Serialization;
namespace BoneSoft.CSS {
/// <summary></summary>
public class Function {
private string name;
private Expression expression;
/// <summary></summary>
[XmlAttribute("name")]
public string Name {
get { return name; }
set { name = value; }
}
/// <summary></summary>
[XmlElement("Expression")]
public Expression Expression {
get { return expression; }
set { expression = value; }
}
/// <summary></summary>
/// <returns></returns>
public override string ToString() {
/*
function<out Function func> = (. func = new Function();
Expression exp = null;
.)
ident (. func.Name = t.val; .)
'(' expr<out exp> (. func.Expression = exp; .)
')'
.
*/
System.Text.StringBuilder txt = new System.Text.StringBuilder();
txt.AppendFormat("{0}(", name);
if (expression != null) {
bool first = true;
foreach (Term t in expression.Terms) {
//if (t.Value.EndsWith("=")) {
if (first) {
first = false;
} else if (!t.Value.EndsWith("=")) {
txt.Append(", ");
}
bool quoteMe = false;
if (t.Type == TermType.String && !t.Value.EndsWith("=")) {
quoteMe = true;
}
if (quoteMe) { txt.Append("'"); }
txt.Append(t.ToString());
if (quoteMe) { txt.Append("'"); }
}
}
txt.Append(")");
return txt.ToString();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been in software development for more than a decade now. Originally with ASP 2.0 and VB6. I worked in Japan for a year doing Java. And have been with C# ever since.
In 2005 I founded
BoneSoft Software where I sell a small number of developer tools.