Exemplo n.º 1
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));
            }
        }
Exemplo n.º 2
0
        private void mnuFileExportDB45Chapters_Click(object sender, EventArgs e)
        {
            Model.EATree element = GetElement();
            if (element == null)
            {
                return;
            }

            string fileName = GetFileName("xml", "DocBook 4.5 (*.xml)|*.xml", "Save As DocBook 4.5 with Chapters");

            if (fileName == null)
            {
                return;
            }

            try {
                using (Model.ITreeExport exportFormat = new Model.DocBook45ChapterExport(fileName)) {
                    exportFormat.ExportTree(element, false);
                }
            } catch (System.Exception exception) {
                EATrace.XmiImport(System.Diagnostics.TraceEventType.Warning, "EAExport DocBook 4.5 Chapter Export Failure: {0}", exception.Message);
                MessageBox.Show(exception.Message, "EAExport DocBook 4.5 Chapter Export Failure");
            }
        }