Example #1
0
        public static void Start()
        {
            if (!Arguments.Contains("file"))
            {
                Out("Please specify the js literal file to analyze", ConsoleColor.Cyan);
                Pause();
                Environment.Exit(1);
            }

            FileInfo file = new FileInfo(Arguments["file"]);

            if (!file.Exists)
            {
                Out("The specified file was not found", ConsoleColor.Red);
                Pause();
                Environment.Exit(1);
            }

            string literalName = "breve";

            if (Arguments.Contains("obj"))
            {
                literalName = Arguments["obj"];
            }

            string name = literalName.PascalCase();

            Dictionary <Languages, Type> formatTypes = new Dictionary <Languages, Type>
            {
                { Languages.cs, typeof(CSharpFormat) },
                { Languages.java, typeof(JavaFormat) },
            };
            Languages lang = Languages.java;

            if (Arguments.Contains("lang"))
            {
                if (Arguments["lang"].Equals("C#"))
                {
                    lang = Languages.cs;
                }
            }

            Type formatType = formatTypes[lang];

            if (Arguments.Contains("classic"))
            {
                formatType = typeof(JavaClassicFormat);
            }

            string         json      = file.JsonFromJsLiteralFile(literalName);
            JObject        obj       = (JObject)JsonConvert.DeserializeObject(json);
            BreveInfo      info      = new BreveInfo(name, obj, lang);
            BreveGenerator generator = BreveGenerator.Create(formatType, info);

            generator.Go(file.FullName, "{Name}.{Extension}".NamedFormat(new { Name = name, Extension = lang.ToString() }));
            Out("Breve object generation complete", ConsoleColor.Cyan);
            Pause();
        }
Example #2
0
        public static void Start()
        {
            if (!Arguments.Contains("file"))
            {
                Out("Please specify the js literal file to analyze", ConsoleColor.Cyan);
                Pause();
                Environment.Exit(1);
            }

            FileInfo file = new FileInfo(Arguments["file"]);

            if (!file.Exists)
            {
                Out("The specified file was not found", ConsoleColor.Red);
                Pause();
                Environment.Exit(1);
            }

            string literalName = "breve";

            if (Arguments.Contains("obj"))
            {
                literalName = Arguments["obj"];
            }

            string name = literalName.PascalCase();

            Languages lang = Languages.java;

            if (Arguments.Contains("lang"))
            {
                if (Arguments["lang"].Equals("C#"))
                {
                    lang = Languages.cs;
                }
            }

            string         json      = file.JsonFromJsLiteralFile(literalName);
            JObject        obj       = (JObject)JsonConvert.DeserializeObject(json);
            BreveInfo      info      = new BreveInfo(name, obj);
            BreveGenerator generator = BreveGenerator.Create(lang, info);

            generator.Go("{Name}.{Extension}".NamedFormat(new { Name = name, Extension = lang.ToString() }));
            Out("Breve object generation complete", ConsoleColor.Cyan);
            Pause();
        }