コード例 #1
0
ファイル: ExportTool.cs プロジェクト: mpostol/ASMD
        private static bool CheckIfExportIsPossibleAndPrepareListOfTerms(IModelNodeAdvance imna, out List <TermWithDefinitionStructure> listOfAllTerms)
        {
            if (imna == null)
            {
                MessageBox.Show(Resources.ExportTool_NoNodeIsSelected, Resources.ExportTool_Window_Name, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                listOfAllTerms = null;
                return(false);
            }
            listOfAllTerms = new List <TermWithDefinitionStructure>();
            if (imna.NodeType == NodeTypeEnum.ProjectNode)
            {
                foreach (IModelNodeAdvance imnaInDictionary in ((imna.GetFolders()).Values))
                {
                    if (imnaInDictionary.NodeType == NodeTypeEnum.ModelNode)
                    {
                        List <TermWithDefinitionStructure> temp_listOfAllTerms = new List <TermWithDefinitionStructure>();
                        if (CheckIfExportIsPossibleAndPrepareListOfTerms(imnaInDictionary, out temp_listOfAllTerms))
                        {
                            listOfAllTerms.AddRange(temp_listOfAllTerms);
                        }
                    }
                }
            }
            else
            {
                TermWithDefinitionStructure term = null;
                if (imna.NodeType == NodeTypeEnum.ModelNode)
                {
                    foreach (KeyValuePair <FolderType, IEnumerable <IModelNodeAdvance> > item in imna.GetFolders())
                    {
                        foreach (IModelNodeAdvance imnaInProject in item.Value)
                        {
                            term = CreateTermWithDefinition(imnaInProject);
                            if (term != null)
                            {
                                listOfAllTerms.Add(term);
                            }
                        }
                    }
                }
                else
                {
                    term = CreateTermWithDefinition(imna);
                    if (term != null)
                    {
                        listOfAllTerms.Add(term);
                        foreach (FolderType folderType in FolderType.GetValues(typeof(FolderType)))
                        {
                            if (GetFolder(imna, folderType) != null)
                            {
                                foreach (IModelNodeAdvance imnaInFolder in GetFolder(imna, folderType))
                                {
                                    term = CreateTermWithDefinition(imnaInFolder);
                                    if (term != null)
                                    {
                                        listOfAllTerms.Add(term);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(Resources.ExportTool_cannot_expot_wrong_node, Resources.ExportTool_Window_Name, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                        return(false);
                    }
                }
            }

            return(true);
        }