public void _24_2_ChangerDescriptorFromJsonWithFinally() { var basePath = Path.Combine(Application.dataPath, "AutomatineTest/TestGenerated/Editor"); var autoGenOutputPath = Path.Combine(basePath, "_24_2_ChangerDescriptorFromJsonWithFinally.json"); { // write to json. var classGenParam = new ChangerData( "TestRouteId2", "TestRoute2", "parentAutoId", new List <string> { "this changer is for change move or not." }, new List <BranchData>(), new FinallyBranchData( "MoveAuto", new List <string> { "Move" } ) ); var serialized = JsonUtility.ToJson(classGenParam); // write json file using (var sw = new StreamWriter(autoGenOutputPath)) { sw.Write(serialized); } } { // read json file var body = string.Empty; using (var sr = new StreamReader(autoGenOutputPath)) { body = sr.ReadToEnd(); } var deserialized = JsonUtility.FromJson <ChangerData>(body); var changerName = deserialized.changerName; var commentLines = deserialized.comments; var branches = deserialized.branchs; var finallyBranch = deserialized.finallyBranch; var desc = AutoDescriptor.Changer(changerName, commentLines, branches, finallyBranch); var outputPath = Path.Combine(basePath, "_24_2_ChangerDescriptorFromJsonWithFinally.cs"); // write class file using (var sw = new StreamWriter(outputPath)) { sw.Write(desc); } } }
public void _24_3_ChangerDescriptorFromJsonWithBranchesAndFinally() { var basePath = Path.Combine(Application.dataPath, "AutomatineTest/TestGenerated/Editor"); var autoGenOutputPath = Path.Combine(basePath, "_24_3_ChangerDescriptorFromJsonWithBranchesAndFinally.json"); { // write to json. var classGenParam = new ChangerData( "TestRouteId3", "TestRoute3", "parentAutoId", new List <string> { "this changer is for change move or not." }, new List <BranchData> { new BranchData( new List <string> { "comment for branchName0" }, new List <ConditionBindData> { new ConditionBindData(ChangerCondKey.CONTAINS, new List <ConditionTypeValueData> { new ConditionTypeValueData("Act", "SPAWN") }) }, "MoveAuto", false, new List <string> { "Move" } ), new BranchData( new List <string> { "comment for branchName1" }, new List <ConditionBindData> { new ConditionBindData(ChangerCondKey.CONTAINS, new List <ConditionTypeValueData> { new ConditionTypeValueData("Act", "SPAWN") }) }, string.Empty, true, new List <string>() ) }, new FinallyBranchData( "MoveAuto", new List <string> { "Move" } ) ); var serialized = JsonUtility.ToJson(classGenParam); // write json file using (var sw = new StreamWriter(autoGenOutputPath)) { sw.Write(serialized); } } { // read json file var body = string.Empty; using (var sr = new StreamReader(autoGenOutputPath)) { body = sr.ReadToEnd(); } var deserialized = JsonUtility.FromJson <ChangerData>(body); var changerName = deserialized.changerName; var commentLines = deserialized.comments; var branches = deserialized.branchs; var finallyBranch = deserialized.finallyBranch; var desc = AutoDescriptor.Changer(changerName, commentLines, branches, finallyBranch); var outputPath = Path.Combine(basePath, "_24_3_ChangerDescriptorFromJsonWithBranchesAndFinally.cs"); // write class file using (var sw = new StreamWriter(outputPath)) { sw.Write(desc); } } }