コード例 #1
0
		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;
		}
コード例 #2
0
		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)));
				}
			}
		}
コード例 #3
0
		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;
		}