z8018
2 天以前 d8dc91f9c1fece5711e38edd1b1274cb9e579015
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
 
namespace WIDESEA_Core.Helper
{
    public static class MethodInfoExtensions
    {
        /// <summary>
        /// 获取方法的完整名称,包括声明类型的全名和方法名
        /// </summary>
        /// <param name="method">要获取完整名称的方法信息</param>
        /// <returns>返回格式为"声明类型全名.方法名"的字符串,如果声明类型为空则只返回方法名</returns>
        public static string GetFullName(this MethodInfo method)
        {
            if (method.DeclaringType == null)
            {
                return $@"{method.Name}";
            }
 
            return $"{method.DeclaringType.FullName}.{method.Name}";
        }
    }
}