-
Notifications
You must be signed in to change notification settings - Fork 13
Available renderers
Zev Spitz edited this page Jan 10, 2021
·
15 revisions
There are currently 8 available renderers, which can be referred to either by a string or an enum value from BuiltinRenderer.
| Renderer | String | Enum | Language |
|---|---|---|---|
| C# |
|
|
Ignored |
Expression<Func<Person, bool>> expr = p => p.DOB.DayOfWeek == DayOfWeek.Tuesday;
Console.WriteLine(expr.ToString("C#"));
/*
(Person p) => p.DOB.DayOfWeek == DayOfWeek.Tuesday
*/ |
|||
| Visual Basic |
|
|
Ignored |
Console.WriteLine(expr.ToString("Visual Basic"));
/*
Function(p As Person) p.DOB.DayOfWeek = DayOfWeek.Tuesday
*/ |
|||
| Factory methods which produce this expression |
|
|
Required |
Console.WriteLine(expr.ToString("Factory methods"));
/*
// using static System.Linq.Expressions.Expression
var p = Parameter(
typeof(Person),
"p"
);
Lambda(
Equal(
Convert(
MakeMemberAccess(
MakeMemberAccess(p,
typeof(Person).GetProperty("DOB")
),
typeof(DateTime).GetProperty("DayOfWeek")
),
typeof(int)
),
Constant(2)
),
p
)
*/ |
|||
| Dynamic LINQ equivalent of the expression |
|
|
Ignored |
Expression<Func<Person, bool>> expr1 = p =>
p.DOB.DayOfWeek == DayOfWeek.Tuesday ||
p.DOB.DayOfWeek == DayOfWeek.Thursday;
Console.WriteLine(expr1.ToString("Dynamic LINQ"));
/*
DOB.DayOfWeek in (DayOfWeek.Tuesday, DayOfWeek.Thursday)
*/ |
|||
| Tree-like text view of NodeType, Type and Name |
|
BuiltinRenderer.TextualTree
|
Optional |
Expression<Func<Person, bool>> expr2 = p => true;
Console.WriteLine(expr2.ToString("Textual tree", "C#"));
/*
Lambda (Func<Person, bool>)
· Parameters[0] - Parameter (Person) p
· Body - Constant (bool) = true
*/ |
|||
| Object graph, described using object/collection initializers |
|
|
Required |
Console.WriteLine(expr2.ToString("Object notation", "C#"));
/*
var p = new ParameterExpression {
Type = typeof(Person),
IsByRef = false,
Name = "p"
};
new Expression<Func<Person, bool>> {
NodeType = ExpressionType.Lambda,
Type = typeof(Func<Person, bool>),
Parameters = new ReadOnlyCollection<ParameterExpression> {
p
},
Body = new ConstantExpression {
Type = typeof(bool),
Value = true
},
ReturnType = typeof(bool)
}
*/ |
|||
| .NET ToString |
|
BuiltinRenderer.ToStringRenderer
|
Ignored |
Console.WriteLine(expr2.ToString("ToString"));
/*
p => True
*/ |
|||
| .NET DebugView |
|
BuiltinRenderer.DebugView
|
Ignored |
Console.WriteLine(expr2.ToString("DebugView"));
/*
.Lambda #Lambda1<System.Func`2[_tests.Person,System.Boolean]>(_tests.Person $p) {
True
}
*/ |
|||