예제 #1
0
        public static void Main(string[] args)
        {
            try
            {
                var commandLineArguments = ParseCommandLineArguments(args);

                var assemblyLoader = new AssemblyLoader();
                var assemblies = assemblyLoader.LoadAssemblies(commandLineArguments.AssemblyFolder);

                var featureProcessor = new FeatureProcessor();
                Features features = featureProcessor.ProcessAssemblies(assemblies);

                var tgfWriter = new TgfWriter();
                tgfWriter.WriteTgfFile(commandLineArguments.OutputPath, features);

                StartYEd(commandLineArguments.OutputPath);

                Console.WriteLine("done output file is " + commandLineArguments.OutputPath);
            }
            catch (Exception exception)
            {
                Console.WriteLine("failed with exception:");
                Console.WriteLine(exception);
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            try
            {
                AbsoluteFilePath outputPath = null;
                AbsoluteFolderPath assemblyFolder = null;
                bool includeFactories = false;
                bool includeDependencies = false;
                AbsoluteFilePath yedPath = @"C:\Program Files (x86)\yWorks\yEd\yEd.exe";
                string outputFormat = "tgf";

                CommandLineConfiguration commandLineConfiguration = CommandLineParserConfigurator
                    .Create()
                        .WithNamed("output", path => outputPath = path)
                            .Required()
                            .DescribedBy("output.tgf", "The absolute output file path. Must have extension .tgf")
                        .WithNamed("folder", folder => assemblyFolder = folder)
                            .Required()
                            .DescribedBy("binary folder", "The folder containing the binaries to analyze. Must contain all direct and indirect dependencies, too.")
                        .WithSwitch("factories", () => includeFactories = true)
                            .DescribedBy("Include information about feature factory.")
                        .WithSwitch("dependencies", () => includeDependencies = true)
                            .DescribedBy("Include information about feature dependencies.")
                        .WithNamed("-yed", path => yedPath = path)
                            .DescribedBy("yEd path", @"Path specifing location of yEd. If not specified, the default installation path is used (C:\Program Files (x86)\yWorks\yEd\yEd.exe).")
                        .WithNamed("format", format => outputFormat = format)
                            .DescribedBy("format", @"Format define dgml or tfg output. The default is tgf. File extension will automatical change to dgml")
                    .BuildConfiguration();

                var parser = new CommandLineParser(commandLineConfiguration);
                ParseResult parseResult = parser.Parse(args);

                if (!parseResult.Succeeded)
                {
                    WriteUsageToConsole(commandLineConfiguration, parseResult);

                    return;
                }

                var assemblyLoader = new AssemblyLoader();
                var assemblies = assemblyLoader.LoadAssemblies(assemblyFolder);

                var featureProcessor = new FeatureProcessor();
                Features features = featureProcessor.ProcessAssemblies(assemblies);

                if (outputFormat.ToLower() == "dgml")
                {
                    outputPath = Path.ChangeExtension(outputPath, ".dgml");
                    DgmlProcessor dgmlProcessor = new DgmlProcessor();
                    dgmlProcessor.Write(features, outputPath);
                }
                else
                {
                    var tgfWriter = new TgfWriter();
                    tgfWriter.WriteTgfFile(outputPath, features, includeFactories, includeDependencies);

                    StartYEd(yedPath, outputPath);
                }

                Console.WriteLine("done output file is " + outputPath);
            }
            catch (Exception exception)
            {
                Console.WriteLine("failed with exception:");
                Console.WriteLine(exception);
            }
        }