Created
October 31, 2009 16:37
-
-
Save jcbozonier/223142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void _GenerateMethod_With_Return( | |
| MethodInfo methodInfo, | |
| TypeBuilder typeBuilder, | |
| string firstMethodName, | |
| Type[] parameterTypes) | |
| { | |
| var returnType = methodInfo.ReturnType; | |
| var methodBuilder = typeBuilder.DefineMethod( | |
| firstMethodName, | |
| MethodAttributes.Public | MethodAttributes.Virtual, | |
| returnType, | |
| parameterTypes); | |
| methodBuilder.InitLocals = true; | |
| var methodIl = methodBuilder.GetILGenerator(); | |
| methodIl.DeclareLocal(returnType); | |
| methodIl.Emit(OpCodes.Ldloc_0); | |
| methodIl.Emit(OpCodes.Ret); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment