static public void DoCheck_IsValid_Table(this TypeData pSheetData, SpreadSheetConnector pConnector, Action <string> OnError) { bool bIsEnum = pSheetData.eType == ESheetType.Enum; pSheetData.ParsingSheet(pConnector, (listRow, strText, iRow, iColumn) => { if (bIsEnum) { Dictionary <int, EEnumHeaderType> mapEnumType = new Dictionary <int, EEnumHeaderType>(); EEnumHeaderType eType = EEnumHeaderType.EnumNone; if (Enum.TryParse(strText, out eType)) { // mapEnumType.Add(,eType) if (eType == EEnumHeaderType.EnumType) { for (int i = iColumn; i < listRow.Count; i++) { string strTextOtherColumn = (string)listRow[i]; if (Enum.TryParse(strTextOtherColumn, out eType) == false) { OnError?.Invoke($"테이블 유효성 체크 - 이넘 파싱 에러"); return; } if (mapEnumType.ContainsKey(iColumn) == false) { mapEnumType.Add(iColumn, eType); } } } return; } if (mapEnumType.ContainsKey(iColumn) == false) { return; } switch (mapEnumType[iColumn]) { case EEnumHeaderType.EnumType: case EEnumHeaderType.EnumValue: if (string.IsNullOrEmpty(strText)) { OnError?.Invoke($"테이블 유효성 체크 - 이넘 파싱 에러"); return; } break; } } else { } }); }
private static Task Parsing_OnEnum(TypeData pSheetData, ISheetConnector pConnector, CodeFileBuilder pCodeFileBuilder) { Dictionary <int, EEnumHeaderType> mapEnumType = new Dictionary <int, EEnumHeaderType>(); Dictionary <string, CodeTypeDeclaration> mapEnumValue = new Dictionary <string, CodeTypeDeclaration>(); return(pSheetData.ParsingSheet_UseTask(pConnector, (listRow, strText, iRow, iColumn) => { EEnumHeaderType eType = EEnumHeaderType.EnumNone; if (Enum.TryParse(strText, out eType)) { if (eType == EEnumHeaderType.EnumType) { if (mapEnumType.ContainsKey(iColumn) == false) { mapEnumType.Add(iColumn, eType); } for (int i = iColumn; i < listRow.Count; i++) { string strTextOtherColumn = (string)listRow[i]; if (Enum.TryParse(strTextOtherColumn, out eType)) { if (mapEnumType.ContainsKey(i) == false) { mapEnumType.Add(i, eType); } } } } return; } if (mapEnumType.TryGetValue(iColumn, out eType) == false) { return; } if (eType != EEnumHeaderType.EnumType) { return; } if (mapEnumValue.ContainsKey(strText) == false) { mapEnumValue.Add(strText, pCodeFileBuilder.AddCodeType(strText, ESheetType.Enum)); } EnumFieldData pFieldData = new EnumFieldData(); for (int i = iColumn; i < listRow.Count; i++) { if (mapEnumType.TryGetValue(i, out eType)) { string strNextText = (string)listRow[i]; switch (eType) { case EEnumHeaderType.EnumValue: pFieldData.strValue = strNextText; break; case EEnumHeaderType.NumberValue: pFieldData.iNumber = int.Parse(strNextText); break; case EEnumHeaderType.Comment: pFieldData.strComment = strNextText; break; } } } if (string.IsNullOrEmpty(pFieldData.strValue)) { throw new Exception($"이넘인데 값이 없습니다 - 타입 : {mapEnumValue[strText].Name}"); } mapEnumValue[strText].AddEnumField(pFieldData); })); }