示例#1
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var options = new CommandLineOptions();

            if (Parser.Default.ParseArgumentsStrict(args, options) && ValidateOptions(options))
            {
                new Program().Run(options);
            }
        }
示例#2
0
        private static bool ValidateOptions(CommandLineOptions options)
        {
            if (string.IsNullOrEmpty(options.Namespace))
            {
                Console.WriteLine("Please provide a valid namespace. It cannot be empty.");
                return false;
            }

            if (string.IsNullOrEmpty(options.SourcePackage) || !File.Exists(options.SourcePackage))
            {
                Console.WriteLine("Unable to find a source package at {0}.", options.SourcePackage);
                return false;
            }

            try
            {
                Directory.CreateDirectory(Path.Combine(options.OutputDirectory));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to locate or create the output directory [{0}].", ex.Message);
                return false;
            }

            // We won't bother with error messages here, just treat empty values as default.
            if (string.IsNullOrEmpty(options.PageBaseClass))
            {
                options.PageBaseClass = ComposerMigrationOptions.Default.PageBaseClass;
            }
            if (string.IsNullOrEmpty(options.BlockBaseClass))
            {
                options.PageBaseClass = ComposerMigrationOptions.Default.BlockBaseClass;
            }

            return true;
        }
示例#3
0
 private static void ConfigureContainer(CommandLineOptions options)
 {
     ContainerBootstrapper.Bootstrap();
     ObjectFactory.Inject<IComposerTranformationOptions>(options);
     ObjectFactory.Inject<ICodeGenerationOptions>(options);
 }
示例#4
0
        private void Run(CommandLineOptions options)
        {
            InitalizeLogger(options.Verbose ? LogLevel.Debug : LogLevel.Info);
            ConfigureContainer(options);
            var logger = LogManager.GetCurrentClassLogger();

            logger.InfoFormat("Generating classes from '{0}' and saving output to '{1}'", options.SourcePackage, options.OutputDirectory);

            var packageReader = ObjectFactory.GetInstance<ImportPackageReader>();
            Generate(packageReader, options.SourcePackage, options.OutputDirectory);
        }