Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var options = new SingleOptions();

            CommandLine.Parser.Default.ParseArguments <BatchOptions, SingleOptions>(args)
            .WithParsed <SingleOptions>(o =>
            {
                GenerateSingle(o);
            })
            .WithParsed <BatchOptions>(batchOption =>
            {
                GenerateBatch(batchOption);
            });
        }
Ejemplo n.º 2
0
        public static void GenerateSingle(SingleOptions options)
        {
            var json = "";

            if (File.Exists(options.InputJsonFile))
            {
                json = File.OpenText(options.InputJsonFile).ReadToEnd();
            }
            else
            {
                Console.WriteLine(String.Format("Cannot find input file '{0}'", options.InputJsonFile));
            }
            var info = new FileInfo(options.InputJsonFile);

            var targetFolder = info.Directory.FullName;

            if (options.TargetFolder != null)
            {
                targetFolder = options.TargetFolder;
            }

            JsonClassGenerator gen = new JsonClassGenerator()
            {
                Namespace          = options.Namespace,
                Example            = json,
                InternalVisibility = options.InternalVisibility,
                SingleFile         = options.SingleFile,
                UsePascalCase      = options.UsePascalCase,
                NoHelperClass      = true,
                UseProperties      = options.UseProperties,
                TargetFolder       = targetFolder,
                MainClass          = options.MainClass,
                UseNestedClasses   = options.UseNestedClasses
            };

            Console.WriteLine("Generating: " + options.Namespace + "." + options.MainClass);
            gen.GenerateClasses();
        }