Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ReflectionUtility
- {
- private static System.Reflection.MethodBase GetCallingMethod()
- {
- return new System.Diagnostics.StackTrace().GetFrame(2).GetMethod();
- }
- public static string GetCallingMethodFullNameReturnParametertypes()
- {
- return MethodFullNameReturnParametertypes(GetCallingMethod());
- }
- private static string MethodFullNameReturnParametertypes(System.Reflection.MethodBase method)
- {
- return string.Format("{0} {1}.{2} ({3})",
- ((System.Reflection.MethodInfo)method).ReturnType, // System.Void, System.Int32 etc.
- method.DeclaringType.FullName, // MyNamespace.MyClass.
- method.Name, // MyMethod.
- string.Join(",", method.GetParameters().Select(p => p.ParameterType.ToString() + " " + p.Name).ToArray()) // () or (int) or (int,string) etc.
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement