private static string GenerateReadFunctionsFile(BdatTables info) { var sb = new Indenter(); sb.AppendLine("// ReSharper disable InconsistentNaming"); sb.AppendLine("// ReSharper disable UnusedMember.Global"); sb.AppendLine("// ReSharper disable UseObjectOrCollectionInitializer"); sb.AppendLine("// ReSharper disable UnusedParameter.Global").AppendLine(); sb.AppendLine("using System;"); sb.AppendLine("using XbTool.Types").AppendLine(); sb.AppendLine("namespace XbTool.Serialization"); sb.AppendLineAndIncrease("{"); sb.AppendLine("public static class ReadFunctions"); sb.AppendLineAndIncrease("{"); bool firstFunction = true; foreach (var type in info.Types) { if (!firstFunction) { sb.AppendLine(); } firstFunction = false; GenerateReadFunction(type, sb); } sb.AppendLine(); GenerateSetReferencesFunction(sb, info); sb.DecreaseAndAppendLine("}"); sb.DecreaseAndAppendLine("}"); return(sb.ToString()); }
private static string GenerateBdatCollectionFile(BdatTables info) { var sb = new Indenter(); sb.AppendLine("// ReSharper disable InconsistentNaming"); sb.AppendLine("// ReSharper disable UnassignedField.Global"); sb.AppendLine("// ReSharper disable UnusedMember.Global").AppendLine(); sb.AppendLine("using System;"); sb.AppendLine("using XbTool.Bdat;").AppendLine(); sb.AppendLine("using XbTool.Types"); sb.AppendLineAndIncrease("{"); sb.AppendLine("[Serializable]"); sb.AppendLine("public class BdatCollection"); sb.AppendLineAndIncrease("{"); foreach (var type in info.Types) { foreach (string table in type.TableNames.OrderBy(x => x)) { sb.AppendLine($"public BdatTable<{type.Name}> {table};"); } } sb.DecreaseAndAppendLine("}"); sb.DecreaseAndAppendLine("}"); return(sb.ToString()); }
private static string GenerateTypesFile(BdatTables info) { var sb = new Indenter(); sb.AppendLine("// ReSharper disable InconsistentNaming"); sb.AppendLine("// ReSharper disable NotAccessedField.Global"); sb.AppendLine(); sb.AppendLine("using System;"); sb.AppendLine("using XbTool.Bdat;"); sb.AppendLine(); sb.AppendLine("namespace XbTool.Types"); sb.AppendLineAndIncrease("{"); for (int i = 0; i < info.Types.Length; i++) { if (i != 0) { sb.AppendLine(); } GenerateType(info.Types[i], sb); } sb.DecreaseAndAppendLine("}"); return(sb.ToString()); }