Exemple #1
0
            protected override bool DoTranslate(
                Match match,
                DynamicExpression dynamicExpression,
                TranslationContext context,
                out string translated)
            {
                var subjectObject   = dynamicExpression.Arguments.First();
                var subject         = context.Translate(subjectObject);
                var methodName      = match.Groups["MethodName"].Value;
                var method          = subjectObject.Type.GetPublicMethod(methodName);
                var methodArguments = dynamicExpression.Arguments.Skip(1).ToArray();

                var methodInfo = GetMethodInfo(
                    methodName,
                    method,
                    methodArguments,
                    dynamicExpression.Type);

                translated = MethodCallExpressionTranslator.GetMethodCall(
                    subject,
                    methodInfo,
                    methodArguments,
                    dynamicExpression,
                    context);

                return(true);
            }
 private static string TranslateMethodConversion(UnaryExpression cast, TranslationContext context)
 {
     return(MethodCallExpressionTranslator.GetMethodCall(
                cast.Method.DeclaringType.GetFriendlyName(),
                new BclMethodInfoWrapper(cast.Method),
                new[] { cast.Operand },
                cast,
                context));
 }
            private string TranslateListBinding(MemberBinding binding, TranslationContext context)
            {
                var listBinding = (MemberListBinding)binding;

                var listInitialisers = listBinding
                                       .Initializers
                                       .Project(init => IsStandardAddMethod(init)
                        ? context.TranslateAsCodeBlock(init.Arguments.First())
                        : MethodCallExpressionTranslator.GetMethodCall(new BclMethodInfoWrapper(init.AddMethod), init.Arguments, context))
                                       .ToArray();

                return(GetInitialisation(listBinding.Member.Name + " =", listInitialisers));
            }