zoukankan      html  css  js  c++  java
  • C#获得类的方法和方法参数

      Type t = typeof(CommonController);
    
    
                StringBuilder str = new StringBuilder();
    
                MethodInfo[] methors = t.GetMethods(BindingFlags.Instance | BindingFlags.Public);
                var md = t.GetCustomAttribute<System.ComponentModel.DescriptionAttribute>();
                str.AppendFormat("路由:" + t.Name).AppendLine("");
                str.AppendFormat("描述" + md.Description).AppendLine("");
    
                foreach (var v in methors)
                {
    
                    var af = v.GetCustomAttribute<Models.Attribute.APIFunctionAttribute>();
                    if (af != null)
                    {
                        str.AppendFormat("	功能标识:{0}", v.Name).AppendLine("");
                        str.AppendFormat("	功能描述:{0}", af.Description).AppendLine("");
                        ParameterInfo[] ps = v.GetParameters();
                        str.AppendFormat("	参数:总数{0}", ps.Length).AppendLine("");
                        foreach (ParameterInfo p in ps)
                        {
                            str.AppendFormat("		名称{0}", p.Name).AppendLine("");
                            str.AppendFormat("		类型{0}", p.ParameterType.FullName).AppendLine("");
                        }
                    }
    慎于行,敏于思!GGGGGG
  • 相关阅读:
    找出优先要作的工作
    我要作技术研发了
    确定配色方案
    今天公司搬家
    要作界面原型了
    使用自已的命名空间
    进行审核了
    那里有皮肤软件工开发包的源码???
    发葡萄
    作业务规则挺难
  • 原文地址:https://www.cnblogs.com/GarsonZhang/p/6001317.html
Copyright © 2011-2022 走看看