Esempio n. 1
0
        private void writeDocumentToFile(XmlDocument docToWrite, String changesExtension)
        {
            String filePath     = null;
            String currentValue = MocaTreeUtil.xmlDocumentToString(docToWrite);

            if (changesExtension != null)
            {
                filePath = Path.Combine(tempDirectoryPath, fileName + "." + changesExtension + ".moca.xmi");
            }

            else
            {
                filePath = Path.Combine(tempDirectoryPath, fileName + ".moca.xmi");
            }

            String dirName = new FileInfo(filePath).DirectoryName;

            if (!(Directory.Exists(dirName)))
            {
                Directory.CreateDirectory(dirName);
            }

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            File.AppendAllText(filePath, currentValue);
        }
Esempio n. 2
0
        public String getXMLDocumentString()
        {
            //create xml stub with a single root node
            XmlDocument xmlDocStub = MocaTreeUtil.createMocaXMLDoc();
            //parse this object to moca element tree
            MocaNode treeElement = this.serializeToMocaTree();

            //parse moca element to xmlElement tree
            XmlElement serializedMocaRoot = treeElement.serializeToXmlTree(xmlDocStub);

            //append new xmlElement to xmlDocument
            xmlDocStub.FirstChild.AppendChild(serializedMocaRoot);

            String documentString = MocaTreeUtil.xmlDocumentToString(xmlDocStub);

            return(documentString);
        }
        /// <summary>
        /// Serializes the current Object 1. to MocaTree and 2. to XmlDocument and saves the XmlDocument
        /// represented as String to a TaggedValue. Last some EA GUI stuff is done which is used to make sure that
        /// the visualization in EA works correctly.
        /// </summary>
        public void saveTreeToEATaggedValue(Boolean updateEaGui)
        {
            String documentString = "";

            if (!this.isIgnored())
            {
                //create xml stub with a single root node
                XmlDocument xmlDocStub = MocaTreeUtil.createMocaXMLDoc();
                //parse this object to moca element tree
                MocaNode treeElement = this.serializeToMocaTree();

                //parse moca element to xmlElement tree
                XmlElement serializedMocaRoot = treeElement.serializeToXmlTree(xmlDocStub);

                //append new xmlElement to xmlDocument
                xmlDocStub.FirstChild.AppendChild(serializedMocaRoot);

                documentString = MocaTreeUtil.xmlDocumentToString(xmlDocStub);
            }

            if (Import.MainImport.ImportBusy)
            {
                foreach (String oldGuid in Import.MainImport.getInstance(Repository, null).OldGuidToNewGuid.Keys)
                {
                    documentString = documentString.Replace(oldGuid, Import.MainImport.getInstance(Repository, null).OldGuidToNewGuid[oldGuid]);
                }
            }
            if (!isLocked())
            {
                EAEcoreAddin.Util.EAUtil.setTaggedValueNotes(Repository, getObjectToBeTagged(), Main.MoflonExportTreeTaggedValueName, documentString);
                if (updateEaGui)
                {
                    doEaGuiStuff();
                }
            }

            refreshSQLObject();
        }