Fauna v10 .NET/C# Driver 1.0.1
 
Loading...
Searching...
No Matches
Expressions.cs
Go to the documentation of this file.
1using System.Linq.Expressions;
2
3namespace Fauna.Util;
4
5internal static class Expressions
6{
7 public static (Expression, Expression[], bool) GetCalleeAndArgs(MethodCallExpression expr) =>
8 expr.Object switch
9 {
10 null => (expr.Arguments.First(), expr.Arguments.Skip(1).ToArray(), true),
11 var c => (c, expr.Arguments.ToArray(), false),
12 };
13
14 public static LambdaExpression? UnwrapLambda(Expression expr) =>
15 expr.NodeType switch
16 {
17 ExpressionType.Lambda => (LambdaExpression)expr,
18
19 ExpressionType.Convert or
20 ExpressionType.ConvertChecked or
21 ExpressionType.Quote =>
22 UnwrapLambda(((UnaryExpression)expr).Operand),
23 _ => null,
24 };
25}