private static void Execute_CommandLine(CodeTypeDeclaration pCodeType, List <CommandLineArg> listCommandLine) { for (int i = 0; i < listCommandLine.Count; i++) { ECommandLine eCommandLine = (ECommandLine)Enum.Parse(typeof(ECommandLine), listCommandLine[i].strArgName); switch (eCommandLine) { case ECommandLine.comment: pCodeType.AddComment(listCommandLine[i].strArgValue); break; case ECommandLine.baseis: pCodeType.AddBaseInterface(listCommandLine[i].strArgValue); break; case ECommandLine.ispartial: pCodeType.IsPartial = true; break; default: break; } } }
public override Task DoWork(CodeFileBuilder pCodeFileBuilder, ISheetConnector pConnector, TypeData[] arrSheetData, Action <string> OnPrintWorkState) { CodeNamespace pNameSpace = new CodeNamespace(); List <CodeNamespaceImport> listDefaultUsing = new List <CodeNamespaceImport>(); listDefaultUsing.Add(new CodeNamespaceImport("UnityEngine")); List <CommandLineArg> listCommandLine = Parsing_CommandLine(strCommandLine, null); for (int i = 0; i < listCommandLine.Count; i++) { ECommandLine eCommandLine = (ECommandLine)Enum.Parse(typeof(ECommandLine), listCommandLine[i].strArgName); switch (eCommandLine) { case ECommandLine.addusing: listDefaultUsing.Add(new CodeNamespaceImport(listCommandLine[i].strArgValue)); break; case ECommandLine.useusing: pNameSpace.Name = listCommandLine[i].strArgValue; break; } } CodeNamespaceImport[] arrDefaultUsing = listDefaultUsing.ToArray(); pNameSpace.Imports.AddRange(arrDefaultUsing); CodeTypeDeclarationCollection arrTypes = pCodeFileBuilder.GetCodeTypeDeclarationCollection(); List <CodeTypeDeclaration> listType = new List <CodeTypeDeclaration>(); foreach (CodeTypeDeclaration pType in arrTypes) { listType.Add(pType); } HashSet <CodeTypeDeclaration> setExecutedType = new HashSet <CodeTypeDeclaration>(); IEnumerable <CodeTypeDeclaration> listUnitySO = listType.Where(p => string.IsNullOrEmpty(p.Name) == false && p.IsClass); foreach (CodeTypeDeclaration pType in listUnitySO) { TypeData pSaveData = arrSheetData.FirstOrDefault((pSaveDataSheet) => pSaveDataSheet.strFileName == pType.Name); if (pSaveData == null) { continue; } Create_SO(pCodeFileBuilder, pNameSpace, pType, pSaveData); CodeTypeDeclaration[] arrEnumTypes = listType.Where(p => pSaveData.listEnumName.Contains(p.Name)).ToArray(); foreach (var pEnumType in arrEnumTypes) { setExecutedType.Add(pEnumType); } if (pSaveData.eType == ESheetType.Global) { Create_GlobalSOContainer(pCodeFileBuilder, pNameSpace, arrDefaultUsing, pType, arrEnumTypes, pSaveData); } else { Create_SOContainer(pCodeFileBuilder, pNameSpace, arrDefaultUsing, pType, arrEnumTypes, pSaveData); } OnPrintWorkState?.Invoke($"UnitySO - Working SO {pType.Name}"); setExecutedType.Add(pType); } // Others pNameSpace.Types.Clear(); IEnumerable <CodeTypeDeclaration> listOthers = listType.Where(p => string.IsNullOrEmpty(p.Name) == false && setExecutedType.Contains(p) == false); foreach (CodeTypeDeclaration pType in listOthers) { OnPrintWorkState?.Invoke($"UnitySO - Working Others {pType.Name}"); pNameSpace.Types.Add(pType); setExecutedType.Add(pType); } if (pNameSpace.Types.Count != 0) { pCodeFileBuilder.Generate_CSharpCode(pNameSpace, $"{GetRelative_To_AbsolutePath(strExportPath)}/Others"); } return(Task.CompletedTask); }