Advertisement
Guest User

selfelected

a guest
Jan 16th, 2010
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1.     class ReflectionUtility
  2.     {
  3.         private static System.Reflection.MethodBase GetCallingMethod()
  4.         {
  5.             return new System.Diagnostics.StackTrace().GetFrame(2).GetMethod();
  6.         }
  7.         public static string GetCallingMethodFullNameReturnParametertypes()
  8.         {
  9.             return MethodFullNameReturnParametertypes(GetCallingMethod());
  10.         }
  11.         private static string MethodFullNameReturnParametertypes(System.Reflection.MethodBase method)
  12.         {
  13.             return string.Format("{0} {1}.{2} ({3})",
  14.                 ((System.Reflection.MethodInfo)method).ReturnType,    // System.Void, System.Int32 etc.
  15.                 method.DeclaringType.FullName,   // MyNamespace.MyClass.
  16.                 method.Name,   // MyMethod.
  17.                 string.Join(",", method.GetParameters().Select(p => p.ParameterType.ToString() + " " + p.Name).ToArray())   // () or (int) or (int,string) etc.
  18.                 );
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement