Beispiel #1
0
        /// <summary>
        /// Shows the entire contents of the module.
        /// </summary>
        /// <param name="m"></param>
        internal virtual void showModule(Assembly m)
        {
            if (m == null)
            {
                return;
            }

            Type[] classes = m.ManifestModule.GetTypes();
            Array.Sort(classes, TypeComparer.comp);
            for (int j = 0; j < classes.Length; j++)
            {
                if (BaseGenerator.Show(classes[j]))
                {
                    if (showClassNameOnly)
                    {
                        Console.WriteLine(classes[j].FullName);
                    }
                    else
                    {
                        showClass(classes[j]);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Process the arguments passed to the program.  Set all the switches, and
        /// return the non-switch arguments (classnames) in an array of strings.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        internal virtual String[] processArgs(String[] args)
        {
            String p;

            String[] classList = new String[128];
            int      count     = 0;

            bool nextIsModule = false;
            bool CouldBeFileName;

            for (int idx = 0; idx < args.Length; idx++)
            {
                CouldBeFileName = true;
                p = args[idx];

                if (p[0] == '-' || p[0] == '/')
                {
                    CouldBeFileName = false;
                    if (p.Length == 2)
                    {
                        switch (Char.ToLower(p[1]))
                        {
                        case 'a':
                            // abbreviation level
                            idx++;
                            if (idx >= args.Length)
                            {
                                Console.WriteLine("Expected abbreviation level after -a");
                            }
                            else
                            {
                                string level = args[idx];
                                if (level.Equals("long"))
                                {
                                    BaseGenerator.defaultAbbreviation = TypeNames.Long;
                                }
                                else if (level.Equals("medium"))
                                {
                                    BaseGenerator.defaultAbbreviation = TypeNames.Medium;
                                }
                                else if (level.Equals("short"))
                                {
                                    BaseGenerator.defaultAbbreviation = TypeNames.Short;
                                }
                                else
                                {
                                    Console.WriteLine("unrecognized abbreviation level '" + level + "'; ignored");
                                }
                            }
                            break;

                        case 'd':
                            BaseGenerator.showAdvancedness = true;
                            break;

                        // show full package qualifiers on all type names
                        case 'f':
                            BaseGenerator.showFullNames = true;
                            break;

                        case 'm':
                            if (moduleName == null)
                            {
                                // first module name is OK, moduleName will still be null
                                nextIsModule = true;
                            }
                            else
                            {
                                Console.WriteLine("only one module allowed; -m and next arg ignored");
                                // skip the next arg, presumed to be a module name
                                idx++;
                            }
                            break;

                        case 'n':
                            BaseGenerator.showPackage   = BaseGenerator.showPackage;
                            BaseGenerator.showInherited = false;
                            break;

                        // show only the class names contained within the module (requires the -m option)
                        case 'o':
                            showClassNameOnly = true;
                            break;

                        // Don't show banner and class not found errors or other error output.
                        case 'q':
                            BaseGenerator.beQuiet = true;
                            break;

                        case 'p':
                            BaseGenerator.showProtected = false;

                            goto
                        case 'v';

                        case 'v':
                            BaseGenerator.showPackage = false;
                            BaseGenerator.showPrivate = false;
                            break;

                        case 'w':
                            generateWeb = true;
                            break;

                        case '?':
                        case 'h':
                            showHelp = true;
                            break;

                        default:
                            Console.WriteLine("unrecognized option '" + p + "'; ignored");
                            break;
                        }
                    }
                    else if (String.Compare(args[idx], "-noinherit", true) == 0)
                    {
                        BaseGenerator.showPackage   = BaseGenerator.showPackage;
                        BaseGenerator.showInherited = false;
                    }
#if PLATFORM_UNIX
                    else if (p[0] == '/')
                    {
                        // On UNIX system-based platforms it might be a fully qualified file.
                        CouldBeFileName = true;
                    }
#endif
                    else
                    {
                        Console.WriteLine("unrecognized option '" + p + "'; ignored");
                    }
                }
                if (CouldBeFileName)
                {
                    // not a switch, must be a class module name
                    if (nextIsModule)
                    {
                        // it's a module
                        moduleName   = args[idx];
                        nextIsModule = false;
                    }
                    else
                    {
                        // it's a class
                        String name = args[idx];

                        // save off the old allowAbbrev setting so we can turn it on
                        bool b = BaseGenerator.allowAbbreviations;
                        BaseGenerator.allowAbbreviations = true;

                        // leverage the allowAbbreviations setting to expand shortcuts
                        name = BaseGenerator.AbbreviateName(name, "S.C", "System.Collections");
                        name = BaseGenerator.AbbreviateName(name, "S.I", "System.Runtime.InteropServices");
                        name = BaseGenerator.AbbreviateName(name, "S.R", "System.Reflection");
                        name = BaseGenerator.AbbreviateName(name, "S.S", "System.Security");
                        name = BaseGenerator.AbbreviateName(name, "S.X", "System.Xml");
                        name = BaseGenerator.AbbreviateName(name, "S", "System");
                        name = BaseGenerator.AbbreviateName(name, "S.R.R", "System.Runtime.Remoting");
                        name = BaseGenerator.AbbreviateName(name, "S.R.S.F.S", "System.Runtime.Serialization.Formatters.Soap");
                        name = BaseGenerator.AbbreviateName(name, "M", "Microsoft");

                        BaseGenerator.allowAbbreviations = b;

                        classList[count++] = name;
                    }
                }
            }

            if (nextIsModule && moduleName == null)
            {
                Console.WriteLine("option -m not followed by module name; ignored");
            }

            // make a right-sized copy of the classlist array
            String[] newList = new String[count];
            Array.Copy(classList, 0, newList, 0, count);

            return(newList);
        }