private CodeMemberMethod CreateMethod(string methodName, MethodInfo methodInfo)
{
// Create the method
var codeMemberMethod = new CodeMemberMethod
{
Attributes = (MemberAttributes)methodInfo.Attributes,
Name = methodName,
ReturnType = new CodeTypeReference(methodInfo.ReturnType)
};
// Set the return type for the method
// Setup and add the parameters
ParameterInfo[] methodParameters = methodInfo.GetParameters();
foreach (ParameterInfo parameter in methodParameters)
{
codeMemberMethod.Parameters.Add(
new CodeParameterDeclarationExpression(
parameter.ParameterType,
parameter.Name));
}
return codeMemberMethod;
}