Esempio n. 1
0
        public static void GenerateParameterCodes()
        {
            string sharedDir = EditorPrefs.GetString("SharedDirLocation", null);

            if (sharedDir == null)
            {
                Debug.Log("SharedDir Location not specified");
                return;
            }

            String jsonString = File.ReadAllText(sharedDir + "/ParameterCode");

            JArray        parameterCodeEntries = JArray.Parse(jsonString);
            List <string> parameterCodes       = new List <string>();

            foreach (JToken code in parameterCodeEntries)
            {
                parameterCodes.Add(code.Value <string>());
            }

            EnumGenerator generator      = new EnumGenerator("ParameterCode", parameterCodes.ToArray());
            var           classDefintion = generator.TransformText();

            GenerateCodeFile("ParameterCode", classDefintion);
        }
Esempio n. 2
0
        public static void GenerateEnum()
        {
            string sharedDir = EditorPrefs.GetString("SharedDirLocation", null);

            if (sharedDir == null)
            {
                Debug.Log("SharedDir Location not specified");
                return;
            }

            DirectoryInfo enumDir = new DirectoryInfo(sharedDir + "/model/enums");

            foreach (FileInfo file in enumDir.GetFiles())
            {
                String  jsonString      = File.ReadAllText(file.FullName);
                JObject enumDescription = JObject.Parse(jsonString);
                string  enumName        = (string)enumDescription["name"];
                JArray  enumEntryArray  = (JArray)enumDescription["variables"];

                List <string> enumEntries = new List <string>();
                foreach (JToken entry in enumEntryArray)
                {
                    enumEntries.Add(entry.Value <string>());
                }

                EnumGenerator generator      = new EnumGenerator(enumName, enumEntries.ToArray());
                var           classDefintion = generator.TransformText();
                GenerateCodeFile(enumName, classDefintion);
            }
        }