Beispiel #1
0
        public static void Main(string[] args)
        {
            string root = args[0];

            IFileReader       fileReader       = new FileReader();
            IDirectoryBrowser directoryBrowser = new DirectoryBrowser(root, fileReader, new string[] { "node_modules", "$tf", "packages" });

            IDatabaseParser  efDatabaseParser = new EntityFrameworkDatabaseParser();
            IProcedureParser procedureParser  = new InformixProcedureParser();

            IFileParser csFileParser  = new CSFileParser(efDatabaseParser);
            IFileParser sqlFileParser = new SQLFileParser(procedureParser);

            IProjectParser netCoreProjectParser = new NETCoreProjectParser(csFileParser);

            List <ProcedureParseReport> procedureList = new List <ProcedureParseReport>();
            List <ProjectParseReport>   projectList   = new List <ProjectParseReport>();

            int total = 0;

            DirFile file;

            while ((file = directoryBrowser.NextFile()) != null)
            {
                if (file.Extension == "csproj")
                {
                    ProjectParseReport projectReport = netCoreProjectParser.Parse(file);

                    if (projectReport != null)
                    {
                        projectList.Add(projectReport);
                    }
                }
                else if (file.Extension == "sql")
                {
                    FileParseReport procedureReport = sqlFileParser.Parse(file);

                    if (procedureReport != null)
                    {
                        procedureList.AddRange(procedureReport.Procedures);
                    }
                }

                total++;
                UpdateConsoleStatus(total, file.Path, root);
            }

            JsonFileWriter.WriteToFile(procedureList, "procedureReport.json");
            JsonFileWriter.WriteToFile(projectList, "projectReport.json");
        }
        public ProjectParseReport Parse(DirFile file)
        {
            List <FileParseReport> fileReports = new List <FileParseReport>();

            //TODO: Inject
            string           root             = file.Path.Substring(0, file.Path.Length - file.Name.Length);
            DirectoryBrowser directoryBrowser = new DirectoryBrowser(root, new FileReader(), new string[] { "node_modules" });

            DirFile currFile;

            while ((currFile = directoryBrowser.NextFile()) != null)
            {
                List <FileParseReport> currFileReports = new List <FileParseReport>();

                foreach (IFileParser parser in _fileParsers)
                {
                    currFileReports.Add(parser.Parse(currFile));
                }

                fileReports.Add(new FileParseReport(currFile.Name, currFileReports.Where(x => x != null).SelectMany(x => x.Databases), currFileReports.Where(x => x != null).SelectMany(x => x.Procedures)));
            }

            return(new ProjectParseReport(file.Name, GetReferences(file.Content), fileReports));
        }