private Expression IfNotNull(Reference targetReference) { var expression = new MultiStatementExpression(); var arguments = ArgumentsUtil.ConvertToArgumentReferenceExpression(MethodToOverride.GetParameters()); expression.AddStatement(new ReturnStatement( new MethodInvocationExpression( targetReference, MethodToOverride, arguments) { VirtualCall = true })); return expression; }
private void InitOutParameters(MultiStatementExpression expression, ParameterInfo[] parameters) { for (var index = 0; index < parameters.Length; index++) { var parameter = parameters[index]; if (parameter.IsOut) { expression.AddStatement( new AssignArgumentStatement(new ArgumentReference(parameter.ParameterType, index + 1), new DefaultValueExpression(parameter.ParameterType))); } } }
private Expression IfNull(Type returnType) { var expression = new MultiStatementExpression(); InitOutParameters(expression, MethodToOverride.GetParameters()); if (returnType == typeof(void)) { expression.AddStatement(new ReturnStatement()); } else { expression.AddStatement(new ReturnStatement(new DefaultValueExpression(returnType))); } return expression; }