Beispiel #1
0
        private static Options GetParsedArguments(string[] args)
        {
            var options = new Options();
            bool isOk = Parser.Default.ParseArguments(args, options);
            if (!isOk || options.Assemblies==null || options.Assemblies.Count==0)
            {
                Console.WriteLine(options.GetUsage());
                Environment.Exit(1);
            }

            if (options.Path == null || options.Path.Count == 0)
            {
                options.Path = new[] {Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)};
            }
            return options;
        }
Beispiel #2
0
        private static Graph Generate(Options options)
        {
            IEnumerable<string> patterns;
            IEnumerable<string> searchPaths;

            AssemblySearchHelper.OptionsToNamesAndSearchPath(options, out patterns, out searchPaths);
            var assemblyFullNames = AssemblySearchHelper.GetAssemblyFullNames(patterns, searchPaths);

            Console.WriteLine("{0} files found.", assemblyFullNames.Count);
            if (assemblyFullNames.Count == 0) Environment.Exit(1);
            Console.WriteLine("Loading assemblies:");
            var rootName = GenerateResultFileName(assemblyFullNames);

            var ePrev = AnalyzesProgress.Started();
            var analyzer = new Analyzer(eCurrent => { ePrev = ConsoleProgress(eCurrent, ePrev); });

            using(var loadHelper = new AssemblyLoadHelper(searchPaths))
            {
                var assemblies = assemblyFullNames.Select(loadHelper.Load);
                analyzer.Analyze(assemblies, rootName);
            }
            return analyzer.GetGraph();
        }
        public static void OptionsToNamesAndSearchPath(Options options, out IEnumerable<string> patterns, out IEnumerable<string> searchPaths)
        {
            var files = new Stack<string>();
            var paths = new Stack<string>(options.Path);

            foreach (var item in options.Assemblies)
            {
                string pattern;
                if (Path.IsPathRooted(item))
                {
                    pattern = Path.GetFileName(item);
                    string path = Path.GetDirectoryName(item);
                    paths.Push(path);
                }
                else
                {
                    pattern = item;
                }
                files.Push(pattern);
            }

            patterns = files;
            searchPaths = paths;
        }