Пример #1
0
        public static void AddField(this CodeTypeDeclaration pCodeType, FieldTypeData pFieldData, MemberAttributes eAttribute = MemberAttributes.Public)
        {
            CodeMemberField pField = new CodeMemberField();

            pField.Attributes = eAttribute;
            pField.Name       = pFieldData.strFieldName;

            Type pType = TypeParser.GetFieldType_OrNull(pFieldData.strFieldType);

            if (pType == null)
            {
                pField.Type = new CodeTypeReference(pFieldData.strFieldType);
            }
            else
            {
                pField.Type = new CodeTypeReference(pType);
            }

            if (pFieldData.bIsVirtualField)
            {
                pFieldData.strComment = $"자동으로 할당되는 필드입니다. 의존되는 필드 : <see cref=\"{pFieldData.strDependencyFieldName}\"/>";
            }

            if (string.IsNullOrEmpty(pFieldData.strComment) == false)
            {
                pField.Comments.Add(new CodeCommentStatement("<summary>", true));
                pField.Comments.Add(new CodeCommentStatement(pFieldData.strComment, true));
                pField.Comments.Add(new CodeCommentStatement("</summary>", true));
            }

            pCodeType.Members.Add(pField);
        }
Пример #2
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);
        }
Пример #3
0
        public static ListViewItem ConvertListViewItem(this FieldTypeData pFieldData)
        {
            ListViewItem pViewItem = new ListViewItem();

            pFieldData.Reset_ListViewItem(pViewItem);
            pViewItem.Tag = pFieldData;

            return(pViewItem);
        }
Пример #4
0
        private void button_Add_VirtualField_Click(object sender, EventArgs e)
        {
            FieldTypeData pFieldOption = new FieldTypeData("None", "None");

            pFieldOption.bIsVirtualField = true;

            _pSheet_CurrentConnected.listFieldData.Add(pFieldOption);
            listView_Field.Items.Add(pFieldOption.ConvertListViewItem());

            AutoSaveAsync_CurrentSheet();
        }
Пример #5
0
        private void checkBox_FieldKey_IsOverlap_CheckedChanged(object sender, EventArgs e)
        {
            if (listView_Field.SelectedItems.Count == 0)
            {
                return;
            }

            var           pSelectedItem = listView_Field.SelectedItems[0];
            FieldTypeData pFieldData    = (FieldTypeData)pSelectedItem.Tag;

            pFieldData.bIsOverlapKey = checkBox_FieldKey_IsOverlap.Checked;
        }
Пример #6
0
        private void checkBox_DeleteField_OnAfterBuild_CheckedChanged(object sender, EventArgs e)
        {
            if (listView_Field.SelectedItems.Count == 0)
            {
                return;
            }

            var           pSelectedItem = listView_Field.SelectedItems[0];
            FieldTypeData pFieldData    = (FieldTypeData)pSelectedItem.Tag;

            pFieldData.bDeleteThisField_InCode = checkBox_DeleteField_OnCode.Checked;
        }
Пример #7
0
        private void checkBox_ConvertStringToEnum_CheckedChanged(object sender, EventArgs e)
        {
            if (listView_Field.SelectedItems.Count == 0)
            {
                return;
            }

            var           pSelectedItem = listView_Field.SelectedItems[0];
            FieldTypeData pFieldData    = (FieldTypeData)pSelectedItem.Tag;

            pFieldData.bConvertStringToEnum = checkBox_ConvertStringToEnum.Checked;
            textBox_EnumName.Enabled        = checkBox_ConvertStringToEnum.Checked;
        }
Пример #8
0
        private void checkBox_Field_NullOrEmtpy_IsError_CheckedChanged(object sender, EventArgs e)
        {
            if (listView_Field.SelectedItems.Count == 0)
            {
                return;
            }

            var           pSelectedItem = listView_Field.SelectedItems[0];
            FieldTypeData pFieldData    = (FieldTypeData)pSelectedItem.Tag;

            pFieldData.bIsKeyField = checkBox_Field_ThisIsKey.Checked;
            checkBox_FieldKey_IsOverlap.Enabled = pFieldData.bIsKeyField;
        }
Пример #9
0
        private void button_Remove_VirtualField_Click(object sender, EventArgs e)
        {
            if (listView_Field.SelectedItems.Count == 0)
            {
                return;
            }

            var           pSelectedItem = listView_Field.SelectedItems[0];
            FieldTypeData pFieldOption  = (FieldTypeData)pSelectedItem.Tag;

            _pSheet_CurrentConnected.listFieldData.Remove(pFieldOption);
            listView_Field.Items.Remove(pSelectedItem);

            AutoSaveAsync_CurrentSheet();
        }
Пример #10
0
        public static void Reset_ListViewItem(this FieldTypeData pFieldData, ListViewItem pViewItem)
        {
            pViewItem.SubItems.Clear();
            pViewItem.SubItems.Add(pFieldData.strFieldType);
            if (pFieldData.bIsVirtualField)
            {
                pViewItem.SubItems.Add(pFieldData.strDependencyFieldName);
            }
            else
            {
                pViewItem.SubItems.Add("X");
            }

            pViewItem.Text = pFieldData.strFieldName;
        }
Пример #11
0
        private void checkBox_IsHeaderField_CheckedChanged(object sender, EventArgs e)
        {
            if (listView_Field.SelectedItems.Count == 0)
            {
                return;
            }

            var           pSelectedItem = listView_Field.SelectedItems[0];
            FieldTypeData pFieldData    = (FieldTypeData)pSelectedItem.Tag;

            if (checkBox_IsHeaderField.Checked)
            {
                _pSheet_CurrentConnected.strHeaderFieldName = pFieldData.strFieldName;
            }
            else if (_pSheet_CurrentConnected.strHeaderFieldName == pFieldData.strFieldName)
            {
                _pSheet_CurrentConnected.strHeaderFieldName = "";
            }
        }
Пример #12
0
        private void button_Save_Field_Click(object sender, EventArgs e)
        {
            if (listView_Field.SelectedItems.Count == 0)
            {
                return;
            }

            var           pSelectedItem = listView_Field.SelectedItems[0];
            FieldTypeData pFieldData    = (FieldTypeData)pSelectedItem.Tag;

            pFieldData.strDependencyFieldName     = (string)comboBox_DependencyField.SelectedItem;
            pFieldData.strDependencyFieldName_Sub = (string)comboBox_DependencyField_Sub.SelectedItem;
            pFieldData.strFieldName = textBox_FieldName.Text;
            pFieldData.strFieldType = textBox_Type.Text;

            pFieldData.bConvertStringToEnum = checkBox_ConvertStringToEnum.Checked;
            pFieldData.strEnumName          = textBox_EnumName.Text;


            pSelectedItem.Text = pFieldData.strFieldName;
            pFieldData.Reset_ListViewItem(pSelectedItem);

            AutoSaveAsync_CurrentSheet();
        }
Пример #13
0
        private void UpdateSheetData(TypeData pSheetData, bool bUpdateUI, bool bSaveSheet)
        {
            int iDefinedTypeRow = -1;
            List <FieldTypeData> listFieldOption = pSheetData.listFieldData;
            HashSet <string>     setRealField    = new HashSet <string>();


            pSheetData.ParsingSheet(pSheetConnector,
                                    ((IList <object> listRow, string strText, int iRowIndex, int iColumnIndex) =>
            {
                if (strText.Contains(":") == false)
                {
                    return;
                }

                if (iDefinedTypeRow == -1)
                {
                    iDefinedTypeRow = iRowIndex;
                }

                if (iDefinedTypeRow != iRowIndex)
                {
                    return;
                }

                string[] arrText = strText.Split(':');
                string strField = arrText[0];
                setRealField.Add(strField);
                FieldTypeData[] arrFieldData = pSheetData.listFieldData.Where(((pField) => (pField.strFieldName == strField))).ToArray();
                if (arrFieldData.Length == 0)
                {
                    arrFieldData = new FieldTypeData[1];
                    arrFieldData[0] = new FieldTypeData(strField, arrText[1]);
                    pSheetData.listFieldData.Add(arrFieldData[0]);
                }

                if (arrFieldData.Length > 1)
                {
                    for (int i = 1; i < arrFieldData.Length; i++)
                    {
                        pSheetData.listFieldData.Remove(arrFieldData[i]);
                    }
                }

                if (bUpdateUI)
                {
                    listView_Field.Items.Add(arrFieldData[0].ConvertListViewItem());
                }
            }));

            var arrDeleteFieldOption = listFieldOption.Where((pFieldOption) => setRealField.Contains(pFieldOption.strFieldName) == false).ToArray();

            if (arrDeleteFieldOption.Length == 0)
            {
                return;
            }

            foreach (FieldTypeData pFieldOption in arrDeleteFieldOption)
            {
                pFieldOption.bIsVirtualField = true;

                if (bUpdateUI)
                {
                    listView_Field.Items.Add(pFieldOption.ConvertListViewItem());
                }
            }

            if (bSaveSheet)
            {
                AutoSaveAsync_CurrentSheet();
            }
        }
Пример #14
0
        private void ListView_Field_SelectedIndexChanged(object sender, EventArgs e)
        {
            FieldTypeData pFieldData = null;
            bool          bEnable    = listView_Field.SelectedIndices.Count > 0;

            if (bEnable)
            {
                pFieldData = (FieldTypeData)listView_Field.SelectedItems[0].Tag;
            }
            else
            {
                groupBox_2_2_SelectedField.Enabled         = false;
                groupBox_2_2_SelectedField_Virtual.Enabled = false;
                checkBox_Field_ThisIsKey.Checked           = false;
                checkBox_FieldKey_IsOverlap.Checked        = false;

                textBox_FieldName.Text = "";
                textBox_Type.Text      = "";
                comboBox_DependencyField.SelectedText     = "";
                comboBox_DependencyField_Sub.SelectedText = "";

                return;
            }

            TypeData pSheetData = (TypeData)checkedListBox_SheetList.SelectedItem;

            if (pSheetData == null)
            {
                return;
            }

            bool bIsEnum = pSheetData.eType == ESheetType.Enum;

            if (bIsEnum)
            {
                return;
            }

            comboBox_DependencyField.Items.Clear();
            comboBox_DependencyField.Items.AddRange(pSheetData.listFieldData.Where((pOption) => pOption.strFieldType == "string").Select((pOption) => pOption.strFieldName).ToArray());

            comboBox_DependencyField_Sub.Items.Clear();
            comboBox_DependencyField_Sub.Items.AddRange(pSheetData.listFieldData.Where((pOption) => pOption.strFieldType == "string").Select((pOption) => pOption.strFieldName).ToArray());

            groupBox_2_2_SelectedField.Enabled         = true;
            groupBox_2_2_SelectedField_Virtual.Enabled = pFieldData.bIsVirtualField;

            textBox_FieldName.Text = pFieldData.strFieldName;
            textBox_Type.Text      = pFieldData.strFieldType;

            checkBox_ConvertStringToEnum.Enabled = pFieldData.strFieldType == "string";
            if (checkBox_ConvertStringToEnum.Enabled)
            {
                checkBox_ConvertStringToEnum.Checked = pFieldData.bConvertStringToEnum;
            }
            else
            {
                checkBox_ConvertStringToEnum.Checked = false;
            }

            textBox_EnumName.Enabled = pFieldData.bConvertStringToEnum;
            if (pFieldData.bConvertStringToEnum)
            {
                textBox_EnumName.Text = pFieldData.strEnumName;
            }
            else
            {
                textBox_EnumName.Text = "";
            }


            checkBox_DeleteField_OnCode.Checked = pFieldData.bDeleteThisField_InCode;
            checkBox_IsHeaderField.Enabled      = pFieldData.bDeleteThisField_InCode == false;
            if (checkBox_IsHeaderField.Enabled)
            {
                checkBox_IsHeaderField.Checked = pSheetData.strHeaderFieldName == pFieldData.strFieldName;
            }
            else
            {
                checkBox_IsHeaderField.Checked = false;
            }

            checkBox_Field_ThisIsKey.Checked    = pFieldData.bIsKeyField;
            checkBox_FieldKey_IsOverlap.Enabled = pFieldData.bIsKeyField;
            if (checkBox_FieldKey_IsOverlap.Enabled)
            {
                checkBox_FieldKey_IsOverlap.Checked = pFieldData.bIsOverlapKey;
            }
            else
            {
                checkBox_FieldKey_IsOverlap.Enabled = false;
            }

            if (string.IsNullOrEmpty(pFieldData.strDependencyFieldName) == false)
            {
                comboBox_DependencyField.SelectedIndex = comboBox_DependencyField.Items.IndexOf(pFieldData.strDependencyFieldName);
            }

            if (string.IsNullOrEmpty(pFieldData.strDependencyFieldName_Sub) == false)
            {
                comboBox_DependencyField_Sub.SelectedIndex = comboBox_DependencyField.Items.IndexOf(pFieldData.strDependencyFieldName_Sub);
            }
        }
Пример #15
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;
                }
            }));
        }