Example #1
0
        static int Main(string[] args)
        {
            Options options;

            try
            {
                options = ParseCommandlineOptions(args);
            }
            catch (ApplicationExitException ex)
            {
                Console.Error.WriteLine(ex.Message);
                return(ex.ExitCode);
            }

            if (options.Mode == Options.ExecutionMode.OutputReport)
            {
                var targetAssemblies = options.TargetAssemblies.Select(Assembly.LoadFrom).ToArray();


                var fomatter = new Formatter();
                fomatter.RegistLogger(Console.Error);

                fomatter.AddRangeFormatters(FormatterFinder.GetFormatters(targetAssemblies));

                var targetTypes = FormatterFinder.GetApplicationRegistriesInterfaceTypes(targetAssemblies);

                var reportFormatContent = ReportTemplate.Default;
                if (string.IsNullOrEmpty(options.FormatFilePath) == false)
                {
                    reportFormatContent = new ReportTemplate(
                        ReportTemplate.Types.Razor,
                        File.ReadAllText(options.FormatFilePath, Encoding.UTF8));
                }


                var content = fomatter.Format(reportFormatContent, targetTypes);

                File.WriteAllText(options.OutputPath, content, Encoding.UTF8);
            }

            if (options.Mode == Options.ExecutionMode.OutputTemplate)
            {
                File.WriteAllText(options.TemplateOutputPath, ReportTemplate.Default.TemplateRawText);
            }

            return(0);
        }