예제 #1
0
        public static string MethodToString(MethodBase Method)
        {
            bool   flag;
            Type   typ = null;
            string str = "";

            if (Method.MemberType == MemberTypes.Method)
            {
                typ = ((MethodInfo)Method).ReturnType;
            }
            if (Method.IsPublic)
            {
                str = str + "Public ";
            }
            else if (Method.IsPrivate)
            {
                str = str + "Private ";
            }
            else if (Method.IsAssembly)
            {
                str = str + "Friend ";
            }
            if ((Method.Attributes & MethodAttributes.Virtual) != MethodAttributes.ReuseSlot)
            {
                if (!Method.DeclaringType.IsInterface)
                {
                    str = str + "Overrides ";
                }
            }
            else if (Symbols.IsShared(Method))
            {
                str = str + "Shared ";
            }
            Symbols.UserDefinedOperator uNDEF = Symbols.UserDefinedOperator.UNDEF;
            if (Symbols.IsUserDefinedOperator(Method))
            {
                uNDEF = Symbols.MapToUserDefinedOperator(Method);
            }
            if (uNDEF != Symbols.UserDefinedOperator.UNDEF)
            {
                if (uNDEF == Symbols.UserDefinedOperator.Narrow)
                {
                    str = str + "Narrowing ";
                }
                else if (uNDEF == Symbols.UserDefinedOperator.Widen)
                {
                    str = str + "Widening ";
                }
                str = str + "Operator ";
            }
            else if ((typ == null) || (typ == VoidType))
            {
                str = str + "Sub ";
            }
            else
            {
                str = str + "Function ";
            }
            if (uNDEF != Symbols.UserDefinedOperator.UNDEF)
            {
                str = str + Symbols.OperatorNames[(int)uNDEF];
            }
            else if (Method.MemberType == MemberTypes.Constructor)
            {
                str = str + "New";
            }
            else
            {
                str = str + Method.Name;
            }
            if (Symbols.IsGeneric(Method))
            {
                str  = str + "(Of ";
                flag = true;
                foreach (Type type2 in Symbols.GetTypeParameters(Method))
                {
                    if (!flag)
                    {
                        str = str + ", ";
                    }
                    else
                    {
                        flag = false;
                    }
                    str = str + VBFriendlyNameOfType(type2, false);
                }
                str = str + ")";
            }
            str  = str + "(";
            flag = true;
            foreach (ParameterInfo info in Method.GetParameters())
            {
                if (!flag)
                {
                    str = str + ", ";
                }
                else
                {
                    flag = false;
                }
                str = str + ParameterToString(info);
            }
            str = str + ")";
            if ((typ == null) || (typ == VoidType))
            {
                return(str);
            }
            return(str + " As " + VBFriendlyNameOfType(typ, true));
        }