예제 #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));
            }
        }
예제 #2
0
파일: EAModel.cs 프로젝트: jcurl/EAExport
        /// <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);
            }
        }
예제 #3
0
        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;
            }
        }