DeserializeAvmDesignXml() public static method

public static DeserializeAvmDesignXml ( TextReader reader ) : avm.Design
reader TextReader
return avm.Design
Esempio n. 1
0
        public Model ImportFile(string inputFilePath, DesignImportMode mode = DesignImportMode.CREATE_DS)
        {
            writeMessage(String.Format("Importing {0}", inputFilePath), MessageType.INFO);

            UnzipToTemp unzip       = null;
            bool        bZipArchive = Path.GetExtension(inputFilePath).Equals(".adp");

            if (bZipArchive)
            {
                unzip = new UnzipToTemp(null);
                List <string> entries = unzip.UnzipFile(inputFilePath);
                inputFilePath = entries.Where(entry => Path.GetDirectoryName(entry) == "" && entry.ToLower().EndsWith(".adm")).FirstOrDefault();
                if (inputFilePath != null)
                {
                    inputFilePath = Path.Combine(unzip.TempDirDestination, inputFilePath);
                }
            }

            Model rtn = null;

            avm.Design ad_import = null;
            using (unzip)
            {
                using (StreamReader streamReader = new StreamReader(inputFilePath))
                {
                    ad_import = CyPhyDesignImporterInterpreter.DeserializeAvmDesignXml(streamReader);
                }
                if (ad_import == null)
                {
                    throw new Exception("Could not load ADM file.");
                }

                rtn = ImportDesign(ad_import, mode);

                // Copy artifacts
                if (bZipArchive)
                {
                    // Delete ADM file from tmp folder
                    File.Delete(inputFilePath);

                    foreach (var keyAndEntity in id2DesignEntity)
                    {
                        string id       = keyAndEntity.Key;
                        var    ca       = keyAndEntity.Value as CyPhy.ComponentAssembly;
                        string tempPath = Path.Combine(unzip.TempDirDestination, id);
                        if (Directory.Exists(tempPath))
                        {
                            var pathCA = ca.GetDirectoryPath(ComponentLibraryManager.PathConvention.ABSOLUTE);
                            DirectoryCopy(tempPath, pathCA, true);
                        }
                    }
                }
            }

            return(rtn);
        }
Esempio n. 2
0
        public Model ImportFile(string inputFilePath, DesignImportMode mode = DesignImportMode.CREATE_DS)
        {
            writeMessage(String.Format("Importing {0}", inputFilePath), MessageType.INFO);

            avm.Design ad_import;
            using (StreamReader streamReader = new StreamReader(inputFilePath))
            {
                ad_import = CyPhyDesignImporterInterpreter.DeserializeAvmDesignXml(streamReader);
            }
            if (ad_import == null)
            {
                throw new Exception("Could not load ACM file.");
            }

            return(ImportDesign(ad_import, mode));
        }