public void Load(System.Xml.Linq.XElement parentNode) { PlexType = IsobaricTypeFactory.Find(parentNode.Element("IsobaricType").Value); IsobaricFile = parentNode.Element("IsobaricFileName").Value; References = (from reffunc in parentNode.Element("References").Elements("Reference") select new IsobaricIndex(reffunc.Attribute("Name").Value, int.Parse(reffunc.Attribute("Index").Value))).ToList(); DatasetMap = new Dictionary <string, List <string> >(); foreach (var ds in parentNode.Element("DatasetMap").Elements("Dataset")) { var name = ds.Element("Name").Value; var value = (from v in ds.Element("Values").Elements("Value") select v.Value).ToList(); DatasetMap[name] = value; } }
public static IsobaricType GetIsobaricType(string fileName) { using (var stream = new FileStream(fileName, FileMode.Open)) { using (var reader = XmlReader.Create(stream)) { if (reader.MoveToElement("IsobaricResult")) { var result = reader.GetAttribute("IsobaricType"); return(IsobaricTypeFactory.Find(result)); } } } throw new Exception(string.Format("Cannot find isobaric type in file {0}", fileName)); }