コード例 #1
0
        private void LoadAssembly()
        {
            var assemblyLoader = new NPlantAssemblyLoader();
            Assembly assembly = assemblyLoader.Load(_filePath);

            var diagramLoader = new NPlantDiagramLoader();

            var diagrams = diagramLoader.Load(assembly);
            _view.Diagrams = diagrams.Select(diagram => new LoadedDiagram(diagram.Diagram)).ToArray();

            _view.ShowDiagramClassesPanel = true;
            _fileToSave = Path.ChangeExtension(_filePath, ".nplant");
        }
コード例 #2
0
        public void Run()
        {
            using (var recorder = _recorder())
            {
                recorder.Log("NPlantRunner Started...");
                recorder.Log(SummarizeConfiguration());

                var      loader   = new NPlantAssemblyLoader(recorder);
                Assembly assembly = loader.Load(_options.AssemblyToScan);

                var diagramLoader = new NPlantDiagramLoader(recorder);
                var diagrams      = diagramLoader.Load(assembly);

                DirectoryInfo outputDirectory = RunInitializeOutputDirectoryStage();

                RunGenerateDiagramImagesStage(outputDirectory, diagrams, recorder);

                recorder.Log("NPlantRunner Finished...");
            }
        }
コード例 #3
0
ファイル: NPlantRunner.cs プロジェクト: leovonwyss/nplant
        public void Run()
        {
            using (var recorder = _recorder())
            {
                recorder.Log("NPlantRunner Started...");
                recorder.Log(SummarizeConfiguration());

                var loader = new NPlantAssemblyLoader(recorder);
                Assembly assembly = loader.Load(_options.AssemblyToScan);

                var diagramLoader = new NPlantDiagramLoader(recorder);
                var diagrams = diagramLoader.Load(assembly);

                DirectoryInfo outputDirectory = RunInitializeOutputDirectoryStage();

                RunGenerateDiagramImagesStage(outputDirectory, diagrams, recorder);

                recorder.Log("NPlantRunner Finished...");
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: nplant/nplant
        static int Main(string[] args)
        {
            try
            {
                var arguments = new CommandLineArgs(args);

                string jarPath = arguments.Jar;

                if (jarPath.IsNullOrEmpty())
                    jarPath = PlantUmlJarExtractor.TryExtractTo(ConsoleEnvironment.ExecutionDirectory);

                if (arguments.Debugger)
                {
                    Debugger.Launch();
                    Debugger.Break();
                }

                var assemblyLoader = new NPlantAssemblyLoader();
                Assembly assembly = assemblyLoader.Load(arguments.Assembly);

                var diagramLoader = new NPlantDiagramLoader();

                var diagrams = diagramLoader.Load(assembly);

                IEnumerable<DiscoveredDiagram> matchingDiagrams = diagrams;

                if(! arguments.Diagram.IsNullOrEmpty())
                    matchingDiagrams = matchingDiagrams.Where(diagram => diagram.Diagram.Name.StartsWith(arguments.Diagram));

                foreach (var matchingDiagram in matchingDiagrams)
                {
                    if (string.IsNullOrEmpty(arguments.Output))
                    {
                        Con.WriteLine("    {0}", matchingDiagram.Diagram.Name);
                    }
                    else
                    {
                        string diagramText = BufferedClassDiagramGenerator.GetDiagramText(matchingDiagram.Diagram);
                        ImageFileGenerationModel model = new ImageFileGenerationModel(diagramText, matchingDiagram.Diagram.Name, arguments.Java, jarPath);

                        DirectoryInfo outputDirectory = new DirectoryInfo(arguments.Output);

                        if (!outputDirectory.Exists)
                            outputDirectory.Create();

                        string path = Path.Combine(outputDirectory.FullName, string.Format("{0}.{1}" ,model.DiagramName, arguments.Format));
                        ImageFormat format = arguments.GetImageFormat();

                        if (format == null)
                        {
                            File.WriteAllText(path, diagramText);
                        }
                        else
                        {
                            NPlantImage nplantImage = new NPlantImage(model.JavaPath, model.Invocation);
                            Image image = nplantImage.Create(model.DiagramText, model.DiagramName);
                            image.Save(path, format);
                        }
                    }
                }

                return 0;
            }
            catch (ConsoleUsageException usageException)
            {
                Con.WriteLine("Fatal Error:");
                Con.WriteLine(usageException.Message);
                Con.WriteLine();
                Con.WriteLine("NPlant.Console.exe Usage");
                Con.WriteLine("------------------------");
            }
            catch (Exception consoleException)
            {
                Con.WriteLine("Fatal Error:");
                Con.WriteLine(consoleException);
            }

            return 1;
        }