예제 #1
0
        /// <summary>Starts the application</summary>
        /// <param name="args">The arguments to start with</param>
        public static void Main(string[] args)
        {
            try {
                // Variables
                InputArguments input = InputArguments.Create(args);

                TypeInfo.ignorePrivate = !input.includePrivate;

                if (input.isList)
                {
                    TypeList list     = TypeList.GenerateList(input.assemblies.ToArray());
                    string   listJson = JsonConvert.SerializeObject(list, Formatting.Indented);

                    File.WriteAllText(input.output, listJson);
                    System.Console.WriteLine($"JSON file ({ input.output }) of listing every type successfully created!");
                    System.Environment.Exit(0);
                }
                else if (input.isHelp)
                {
                    DisplayHelp();
                }

                // Variables
                string   typePath   = input.typePath;
                string[] assemblies = input.assemblies.ToArray();
                TypeInfo info;
                string   json = "";

                if (TypeInfo.GenerateTypeInfo(assemblies, typePath, out info))
                {
                    json = JsonConvert.SerializeObject(info, Formatting.Indented);
                    File.WriteAllText(input.output, json);
                    System.Console.WriteLine($"JSON file ({ input.output }) of peek into type [{ typePath }] successfully created!");
                }
                else
                {
                    System.Console.WriteLine($"Type [{ typePath }] is not found!");
                    DisplayHelp();
                }
            } catch (System.IndexOutOfRangeException) {
                System.Console.WriteLine("Error: Output location not specified");
                DisplayHelp();
            } catch (System.Exception e) {
                System.Console.WriteLine($"Error: { e.Message }");
                DisplayHelp();
            }
        }