IMethodExtensions.cs 738 B

1234567891011121314151617181920212223242526
  1. namespace ILRuntime.CLR.Method
  2. {
  3. public static class IMethodExtensions
  4. {
  5. public static bool IsExtendMethod(this ILMethod im)
  6. {
  7. if (!im.IsStatic || im.ParameterCount == 0)
  8. {
  9. return false;
  10. }
  11. return im.ReflectionMethodInfo.GetCustomAttributes(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false).Length > 0;
  12. }
  13. public static bool IsExtendMethod(this CLRMethod cm)
  14. {
  15. if (!cm.IsStatic || cm.ParameterCount == 0)
  16. {
  17. return false;
  18. }
  19. return cm.MethodInfo.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false);
  20. }
  21. }
  22. }