Exemplo n.º 1
0
        private static void Parsing_OnCode(TypeData pSheetData, SpreadSheetConnector pConnector, CodeFileBuilder pCodeFileBuilder, List <CommandLineArg> listCommandLine)
        {
            var pCodeType = pCodeFileBuilder.AddCodeType(pSheetData.strFileName, pSheetData.eType);
            var mapFieldData_ConvertStringToEnum              = pSheetData.listFieldData.Where((pFieldData) => pFieldData.bConvertStringToEnum).ToDictionary(((pFieldData) => pFieldData.strFieldName));
            var listFieldData_DeleteThisField_OnCode          = pSheetData.listFieldData.Where((pFieldData) => pFieldData.bDeleteThisField_InCode).Select((pFieldData) => pFieldData.strFieldName);
            Dictionary <int, CodeTypeDeclaration> mapEnumType = new Dictionary <int, CodeTypeDeclaration>();


            int iDefinedTypeRow = -1;

            pSheetData.ParsingSheet(pConnector,
                                    (listRow, strText, iRow, iColumn) =>
            {
                // 변수 선언 형식인경우
                if (strText.Contains(":"))
                {
                    if (iDefinedTypeRow == -1)
                    {
                        iDefinedTypeRow = iRow;
                    }

                    if (iDefinedTypeRow != iRow)
                    {
                        return;
                    }

                    string[] arrText    = strText.Split(':');
                    string strFieldName = arrText[0];

                    if (mapFieldData_ConvertStringToEnum.ContainsKey(strFieldName))
                    {
                        FieldTypeData pFieldData = mapFieldData_ConvertStringToEnum[strFieldName];
                        mapEnumType.Add(iColumn, pCodeFileBuilder.AddCodeType(pFieldData.strEnumName, ESheetType.Enum));

                        if (pSheetData.listEnumName.Contains(pFieldData.strEnumName) == false)
                        {
                            pSheetData.listEnumName.Add(pFieldData.strEnumName);
                        }
                    }

                    // 삭제되는 코드인 경우
                    if (listFieldData_DeleteThisField_OnCode.Contains(strFieldName))
                    {
                        return;
                    }

                    pCodeType.AddField(new FieldTypeData(strFieldName, arrText[1]));
                    return;
                }

                // 이넘 Column인 경우 이넘 생성
                if (mapEnumType.ContainsKey(iColumn))
                {
                    mapEnumType[iColumn].AddEnumField(new EnumFieldData(strText));
                    return;
                }
            });

            Execute_CommandLine(pCodeType, listCommandLine);
        }
Exemplo n.º 2
0
        private static CodeTypeDeclaration AddEnumType(TypeData pSheetData, CodeFileBuilder pCodeFileBuilder, string strEnumTypeName)
        {
            var pCodeType_GlobalKey = pCodeFileBuilder.AddCodeType(strEnumTypeName, ESheetType.Enum);

            if (pSheetData.listEnumName.Contains(strEnumTypeName) == false)
            {
                pSheetData.listEnumName.Add(strEnumTypeName);
            }

            return(pCodeType_GlobalKey);
        }
Exemplo n.º 3
0
        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);
            }));
        }
Exemplo n.º 4
0
        private static Task Parsing_OnGlobal(TypeData pSheetData, ISheetConnector pConnector, CodeFileBuilder pCodeFileBuilder)
        {
            var pCodeType_Class = pCodeFileBuilder.AddCodeType(pSheetData.strFileName, pSheetData.eType);

            Dictionary <int, EGlobalColumnType>      mapGlobalColumnType = new Dictionary <int, EGlobalColumnType>();
            Dictionary <string, CodeTypeDeclaration> mapEnumFieldType    = new Dictionary <string, CodeTypeDeclaration>();
            HashSet <string> setGlobalTable_ByType = new HashSet <string>();

            string strKeyFieldName      = "";
            string strTypeFieldName     = "";
            int    iColumnIndex_Type    = -1;
            int    iColumnIndex_Comment = -1;

            return(pSheetData.ParsingSheet_UseTask(pConnector,
                                                   (listRow, strText, iRow, iColumn) =>
            {
                // 변수 선언 형식인경우
                if (strText.Contains(":"))
                {
                    string[] arrText = strText.Split(':');
                    string strFieldName = arrText[0];
                    string strFieldName_Lower = strFieldName.ToLower();

                    for (int i = 0; i < (int)EGlobalColumnType.MAX; i++)
                    {
                        EGlobalColumnType eCurrentColumnType = (EGlobalColumnType)i;
                        if (strFieldName_Lower.Contains(eCurrentColumnType.ToString().ToLower()))
                        {
                            mapGlobalColumnType.Add(iColumn, eCurrentColumnType);

                            switch (eCurrentColumnType)
                            {
                            case EGlobalColumnType.Key:
                                {
                                    FieldTypeData pFieldData = pSheetData.listFieldData.FirstOrDefault(p => p.strFieldName == strFieldName);
                                    if (pFieldData != null)
                                    {
                                        pFieldData.bDeleteThisField_InCode = true;
                                    }

                                    strKeyFieldName = strFieldName;
                                }
                                break;

                            case EGlobalColumnType.Comment:
                                {
                                    FieldTypeData pFieldData = pSheetData.listFieldData.FirstOrDefault(p => p.strFieldName == strFieldName);
                                    if (pFieldData != null)
                                    {
                                        pFieldData.bDeleteThisField_InCode = true;
                                    }
                                    iColumnIndex_Comment = iColumn;
                                }
                                break;

                            case EGlobalColumnType.Type:
                                {
                                    iColumnIndex_Type = iColumn;
                                    strTypeFieldName = strFieldName;
                                    pCodeType_Class.AddField(new FieldTypeData(strFieldName, arrText[1]));

                                    FieldTypeData pFieldData_Type = pSheetData.listFieldData.FirstOrDefault(p => p.strFieldName == strFieldName);
                                    if (pFieldData_Type == null)
                                    {
                                        pSheetData.listFieldData.Add(new FieldTypeData(strFieldName, arrText[1]));
                                    }
                                }
                                break;


                            default:
                                pCodeType_Class.AddField(new FieldTypeData(strFieldName, arrText[1]));
                                break;
                            }

                            return;
                        }
                    }
                }

                // 변수 선언이 아니라 값을 파싱하면 일단 타입부터 확인한다
                if (mapGlobalColumnType.TryGetValue(iColumn, out var eColumnType) == false)
                {
                    return;
                }

                switch (eColumnType)
                {
                case EGlobalColumnType.Key:

                    string strTypeName = (string)listRow[iColumnIndex_Type];
                    string strEnumTypeName = const_GlobalKey_EnumName + "_" + strTypeName;
                    string strEnumFieldName = const_GlobalKey_FieldName + "_" + strTypeName;
                    if (mapEnumFieldType.TryGetValue(strEnumTypeName, out CodeTypeDeclaration pEnumTypeDeclaration) == false)
                    {
                        pEnumTypeDeclaration = AddEnumType(pSheetData, pCodeFileBuilder, strEnumTypeName);
                        mapEnumFieldType.Add(strEnumTypeName, pEnumTypeDeclaration);
                    }


                    FieldTypeData pFieldData_Enum = pSheetData.listFieldData.FirstOrDefault(p => p.strFieldName == strEnumFieldName);
                    if (pFieldData_Enum == null)
                    {
                        pFieldData_Enum = new FieldTypeData(strEnumFieldName, strEnumTypeName);
                        pFieldData_Enum.strDependencyFieldName = strKeyFieldName;
                        pFieldData_Enum.bIsVirtualField = true;
                        pSheetData.listFieldData.Add(pFieldData_Enum);
                    }


                    string strComment = "";
                    if (iColumnIndex_Comment != -1 && iColumnIndex_Comment < listRow.Count)
                    {
                        strComment = (string)listRow[iColumnIndex_Comment];
                    }

                    if (string.IsNullOrEmpty(strComment))
                    {
                        pEnumTypeDeclaration.AddEnumField(new EnumFieldData(strText));
                    }
                    else
                    {
                        pEnumTypeDeclaration.AddEnumField(new EnumFieldData(strText, strComment));
                    }

                    break;

                case EGlobalColumnType.Type:

                    if (setGlobalTable_ByType.Contains(strText))
                    {
                        return;
                    }
                    setGlobalTable_ByType.Add(strText);

                    string strFieldType = (string)listRow[iColumnIndex_Type];
                    FieldTypeData pFieldData = pSheetData.listFieldData.FirstOrDefault(p => p.strFieldName == strTypeFieldName && p.strFieldType == strFieldType);
                    if (pFieldData == null)
                    {
                        pFieldData = new FieldTypeData(strTypeFieldName, strFieldType);
                        pSheetData.listFieldData.Add(pFieldData);
                    }

                    pFieldData.bIsTemp = true;
                    pFieldData.bDeleteThisField_InCode = true;
                    pFieldData.bIsVirtualField = strFieldType != "string";
                    pFieldData.bIsKeyField = true;
                    pFieldData.bIsOverlapKey = true;

                    break;
                }
            }));
        }