You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuCoreExtension.cs 935B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Reflection;
  3. namespace Luticate2.Auth.Utils.Business.Utils
  4. {
  5. public static class LuCoreExtension
  6. {
  7. public static Type GetUnderlyingType(this MemberInfo member)
  8. {
  9. switch (member.MemberType)
  10. {
  11. case MemberTypes.Event:
  12. return ((EventInfo)member).EventHandlerType;
  13. case MemberTypes.Field:
  14. return ((FieldInfo)member).FieldType;
  15. case MemberTypes.Method:
  16. return ((MethodInfo)member).ReturnType;
  17. case MemberTypes.Property:
  18. return ((PropertyInfo)member).PropertyType;
  19. default:
  20. throw new ArgumentException
  21. (
  22. "Input MemberInfo must be if type EventInfo, FieldInfo, MethodInfo, or PropertyInfo"
  23. );
  24. }
  25. }
  26. }
  27. }