System.Linq.Dynamic.ExtendedExpressionParser.PropagateToNullMethod C# (CSharp) Méthode

PropagateToNullMethod() private méthode

Convert Foo(a,b,c)=>(a!=null && b!=null)?Foo(a.Value,b.Value):null;
private PropagateToNullMethod ( Type type, Expression instance, int errorPos, string id, Lazy argumentList ) : Maybe
type Type
instance System.Linq.Expressions.Expression
errorPos int
id string
argumentList Lazy
Résultat Maybe
		private Maybe<Expression> PropagateToNullMethod(Type type, Expression instance, int errorPos, string id, Lazy<Expression[]> argumentList)
		{

			var newArgs = argumentList.Value.Select(a => a.Type.IsNullable() ? Expression.Property(a, "Value") : a).ToArray();
			var methodCall = GenerateMethodCallImpl(type, instance, errorPos, id, Lazy.Create(newArgs));
			return methodCall.Select(e =>
			{

				var test = argumentList.Value.Where(x => x.Type.IsNullable())
					.Select(x => Expression.NotEqual(x, Expression.Constant(null, x.Type)))
					.CombineAnd();

				var needToNullate = e.Type.IsValueType;

				var resultType = needToNullate ? typeof(Nullable<>).MakeGenericType(e.Type) : e.Type;

				var ifTrue = needToNullate ? Expression.Convert(e, resultType) : e;

				var ifFalse = Expression.Constant(null, resultType);


				return (Expression)Expression.Condition(test, ifTrue, ifFalse);
			});

		}