public static Maybe <object> SimpleEval(Expression lambdaContainer) { return(MaybeExtension.OrElse <object>( MaybeExtension.SelectMany( MaybeExtension.SelectMany( MaybeExtension.SelectMany( MaybeExtension.MaybeAs <MethodCallExpression>((object)lambdaContainer, true), (Func <MethodCallExpression, Maybe <ConstantExpression> >) (methodCallExpression => MaybeExtension.MaybeAs <ConstantExpression>((object)methodCallExpression.Object, false)), (methodCallExpression, @object) => { var local_0 = new { methodCallExpression = methodCallExpression, @object = @object }; return local_0; }), param0 => Evaluator.GetParameters(param0.methodCallExpression), (param0, parameters) => { var local_0 = new { par = param0, parameters = parameters }; return local_0; }), param0 => MaybeExtension.ToMaybe <object>(param0.par.methodCallExpression.Method.Invoke(param0.par.@object == null ? (object)null : [email protected], Enumerable.ToArray <object>(param0.parameters))), (param0, lambdaExpression) => lambdaExpression), (Func <Maybe <object> >)(() => Evaluator.Evaluate(lambdaContainer)))); }
public static Maybe <object> Evaluate(Expression argument) { return(MaybeExtension.OrElse <object>(MaybeExtension.Bind <ConstantExpression, object>(MaybeExtension.MaybeAs <ConstantExpression>((object)argument, true), (Func <ConstantExpression, object>)(x => x.Value)), (Func <Maybe <object> >)(() => MaybeExtension.SelectMany(MaybeExtension.SelectMany(MaybeExtension.MaybeAs <MemberExpression>((object)argument, true), (Func <MemberExpression, Maybe <ConstantExpression> >)(memberExpression => MaybeExtension.MaybeAs <ConstantExpression>((object)memberExpression.Expression, false)), (memberExpression, @object) => { var local_0 = new { memberExpression = memberExpression, @object = @object }; return local_0; }), param0 => MaybeExtension.OrElse <object>(MaybeExtension.Bind <PropertyInfo, object>(MaybeExtension.MaybeAs <PropertyInfo>((object)param0.memberExpression.Member, true), (Func <PropertyInfo, object>)(x => x.GetValue([email protected], (object[])null))), (Func <Maybe <object> >)(() => MaybeExtension.Bind <FieldInfo, object>(MaybeExtension.MaybeAs <FieldInfo>((object)param0.memberExpression.Member, true), (Func <FieldInfo, object>)(x => x.GetValue([email protected]))))), (param0, computedValue) => computedValue)))); }