Esempio n. 1
0
        private void mnuFileOpenXmi_Click(object sender, EventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog {
                CheckFileExists = true,
                CheckPathExists = true,
                DefaultExt      = "xml",
                Filter          = "XMI (*.xml)|*.xml",
                Multiselect     = false,
                ShowReadOnly    = true,
                ReadOnlyChecked = true,
                Title           = "Open XMI File"
            };

            openDialog.ShowDialog();
            string fileName = openDialog.FileName;

            if (string.IsNullOrWhiteSpace(fileName))
            {
                return;
            }

            try {
                Model.EAModel loadModel = Model.EAModel.LoadXmi(fileName);
                mnuFileExport.Enabled = true;
                mnuEditSearch.Enabled = true;
                eaModel = loadModel;
                BuildTree();
            } catch (System.Exception exception) {
                EATrace.XmiImport(System.Diagnostics.TraceEventType.Warning, "EAExport Load Failure: {0}", exception.Message);
                MessageBox.Show(exception.Message, "EAExport Load Failure");
            }
        }
Esempio n. 2
0
        private static XmlDocumentFragment LoadXmi(string fileName)
        {
            EAModel model = EAModel.LoadXmi(Path.Combine(Deploy.TestDirectory, fileName));

            using (MemoryStream ms = new MemoryStream()) {
                using (XmlWriter wr = GetWriter(ms))
                    using (DocBook45ChapterExport export = new DocBook45ChapterExport(wr)) {
                        export.ExportTree(model.Root, false);
                    }

                // Export must be disposed here, so that the data is actually written to the stream.
                ms.Flush();
                ms.Seek(0, SeekOrigin.Begin);
                return(LoadDocumentFragment(ms));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Loads the EA Model from an XMI file.
        /// </summary>
        /// <param name="fileName">Name of the file to import.</param>
        /// <returns>An EA Model object.</returns>
        public static EAModel LoadXmi(string fileName)
        {
            EAModel model = new EAModel();

            EATrace.XmiImport(TraceEventType.Information, "Time: {0}", DateTime.Now.ToString("G"));
            EATrace.XmiImport(TraceEventType.Information, "Loading file {0}", fileName);
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

            using (XmlTextReader xmlReader = new XmlTextReader(fs)
            {
                XmlResolver = null,
                DtdProcessing = DtdProcessing.Prohibit
            }) {
                model.LoadXmi(xmlReader);
                model.BuildTree();
                return(model);
            }
        }
        private static StreamReader LoadXmi(string fileName)
        {
            EAModel      model = EAModel.LoadXmi(Path.Combine(Deploy.TestDirectory, fileName));
            MemoryStream ms    = null;

            try {
                ms = new MemoryStream();
                using (CsvDoorsTreePlainExport export = new CsvDoorsTreePlainExport(ms)) {
                    export.ExportTree(model.Root, false);
                }
                ms.Flush();
                ms.Seek(0, SeekOrigin.Begin);
                return(new StreamReader(ms));
            } catch {
                if (ms != null)
                {
                    ms.Dispose();
                }
                throw;
            }
        }