Exemple #1
0
        static public string GenericStr(System.Reflection.MethodInfo m)
        {
            List <string> list = new List <string>();

            foreach (Type t in m.GetGenericArguments())
            {
                list.Add(string.Format("{0}", t.Name));
            }
            return(string.Format("<{0}>", string.Join(",", list.ToArray())));
        }
Exemple #2
0
        static public List <string> ParameterNames(System.Reflection.MethodInfo m)
        {
            List <string> paramnames = new List <string>();

            foreach (System.Reflection.ParameterInfo pi in m.GetParameters())
            {
                paramnames.Add(string.Format("{0} {1}", CleanTypeName(pi.ParameterType), pi.Name));
            }
            return(paramnames);
        }
Exemple #3
0
        static public List <string> GetGenericProperty(System.Reflection.MethodInfo m)
        {
            List <string> list = new List <string>();

            foreach (Type t in m.GetGenericArguments())
            {
                list.Add(string.Format(
                             "{0}",
                             t.Name
                             ));
            }
            return(list);
        }
Exemple #4
0
        static public void GetMethodNode(TreeNode methods, System.Reflection.MethodInfo m)
        {
            if (HasAttribute(System.Reflection.MethodAttributes.SpecialName, m))
            {
                return;
            }
            List <string> paramnames = ParameterNames(m), generics = GetGenericProperty(m);
            TreeNode      method = null;

            if (!(m.DeclaringType == null))
            {
                if (!methods.Nodes.ContainsKey(m.DeclaringType.Name))
                {
                    methods.Nodes.Add(CleanTypeName(m.DeclaringType))
                    .Name = m.DeclaringType.Name;
                }
                method = methods.Nodes[m.DeclaringType.Name].Nodes.Add(
                    string.Format("{1}:{0}", CleanTypeName(m.ReturnType), m.Name));
            }
            else
            {
                method = methods.Nodes.Add(string.Format("{1}", CleanTypeName(m.ReturnType), m.Name));
            }
            method.ImageKey = method.SelectedImageKey = ImageKeyNames.Function;
            method.Text     = string.Format(
                "{0}{1} {2}{3}({4})",
                string.Concat(
                    m.IsVirtual?"virtual ":string.Empty,
                    m.IsPublic?"public ":string.Empty,
                    m.IsPrivate?"private ":string.Empty,
                    m.IsFamily?"(family) ":string.Empty,
                    m.IsStatic?"static ":string.Empty
                    ),
                string.Concat(
                    CleanTypeName(m.ReturnParameter.ParameterType)
                    ),
                m.Name,
                string.Concat(
                    m.IsGenericMethod ? string.Format("<{0}>", string.Join(",", generics.ToArray())):string.Empty
                    ),
                string.Join(", ", paramnames.ToArray())
                );
            method.Tag = m;
        }
Exemple #5
0
 static public string HasAttribute(System.Reflection.MethodAttributes ma, System.Reflection.MethodInfo m, string input)
 {
     return((HasAttribute(ma, m)) ? input : string.Empty);
 }
Exemple #6
0
        static public bool HasAttribute(System.Reflection.MethodAttributes ma, System.Reflection.MethodInfo m)
        {
            int a = (int)m.Attributes, b = (int)ma;

            return((a & b) == b);
        }