use only 2.1 available AppendFormat method
[mono.git] / mcs / class / System.Core / System.Linq.Expressions / InvocationExpression.cs
1 using System.Text;
2 using System.Collections.ObjectModel;
3
4 namespace System.Linq.Expressions
5 {
6     public sealed class InvocationExpression : Expression
7     {
8         #region .ctor
9         internal InvocationExpression(Expression lambda, Type returnType, ReadOnlyCollection<Expression> arguments)
10             : base(ExpressionType.Invoke, returnType)
11         {
12             this.lambda = lambda;
13             this.arguments = arguments;
14         }
15         #endregion
16
17         #region Fields
18         private Expression lambda;
19         private ReadOnlyCollection<Expression> arguments;
20         #endregion
21
22         #region Properties
23         public ReadOnlyCollection<Expression> Arguments
24         {
25             get { return arguments; }
26         }
27
28         public Expression Expression
29         {
30             get { return lambda; }
31         }
32         #endregion
33
34         #region Internal Methods
35         internal override void BuildString(StringBuilder builder)
36         {
37             builder.Append("invoke(");
38
39             // build the lamba expression first
40             lambda.BuildString(builder);
41
42             int argc = arguments.Count;
43             for (int i = 0; i < argc; i++)
44             {
45                 arguments[i].BuildString(builder);
46                 if (i < argc - 1)
47                     builder.Append(", ");
48             }
49
50             builder.Append(")");
51         }
52         #endregion
53     }
54 }