public bool ReadXml(string XmlPath) { Logger.Log(LogLevel.Debug, "InspectRhino\tReadXml: " + XmlPath); XmlDocument doc = new XmlDocument(); doc.Load(XmlPath); XmlNode node = doc.SelectSingleNode("/RhinoExeInfo"); if (node == null) { return(false); } if (node.Attributes == null) { return(false); } XmlAttribute verAttr = node.Attributes["Version"]; if (verAttr == null) { return(false); } string version = verAttr.Value; if (version != "1.0.1") { return(false); } XmlNode exeinfo = doc.SelectSingleNode("/RhinoExeInfo"); RhinoVersion = new Version(XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoVersion", XmlPath)); RhinoSdkVersion = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoSdkVersion", XmlPath); Edition = XmlHelper.SelectSingleNodeInnerText(exeinfo, "Edition", XmlPath); RhinoSdkServiceRelease = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoSdkServiceRelease", XmlPath); RhinoDotNetVersion = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoDotNetVersion", XmlPath); RhinoCommonVersion = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoCommonVersion", XmlPath); RhinoExePath = XmlHelper.SelectSingleNodeInnerText(exeinfo, "RhinoExePath", XmlPath); string platform = XmlHelper.SelectSingleNodeInnerText(exeinfo, "OSPlatform", XmlPath); try { OS = (OSPlatform)Enum.Parse(OS.GetType(), platform); } catch { throw new InvalidOperatingSystemException("Unsupported OS Platform: " + platform); } return(true); }
private void ReadXml101(XmlDocument doc) { XmlNode package = doc.SelectSingleNode("/RhinoInstaller/Package"); if (package == null) { return; } this.VersionNumber = new Version(XmlHelper.SelectSingleNodeInnerText(package, "Version")); this.Title = XmlHelper.SelectSingleNodeInnerText(package, "Title"); // GUID string sGuid = XmlHelper.SelectSingleNodeInnerText(package, "ID"); try { this.ID = new Guid(sGuid); } catch { throw new PackageAuthoringException(string.Format("GUID malformed: '{0}'", sGuid)); } this.UpdateUrl = XmlHelper.SelectSingleNodeInnerText(package, "UpdateUrl"); string os = XmlHelper.SelectSingleNodeInnerText(package, "OS"); try { OS = (OSPlatform)Enum.Parse(OS.GetType(), os); } catch { throw new InvalidOperatingSystemException(os); } XmlNode contentType = package.SelectSingleNode("ContentType"); if (contentType != null) { this.ContentType = PackageContentType.Unknown; PackageContentType t; if (Enum.TryParse(contentType.InnerText, out t)) { this.ContentType = t; } } // Platform, if it exists XmlNodeList platforms = package.SelectNodes("RhinoPlatform"); if (platforms != null) { foreach (XmlNode platform in platforms) { RhinoPlatform p = RhinoPlatform.Unknown; p = (RhinoPlatform)Enum.Parse(p.GetType(), platform.InnerText); if (p != RhinoPlatform.Unknown) { SupportedPlatforms.Add(p); } } } // Culture, if it exists XmlNode culture = package.SelectSingleNode("Locale"); if (null != culture) { if (0 != System.String.CompareOrdinal(culture.InnerText.ToUpperInvariant(), "LOCALEINVARIANT") && 0 != System.String.CompareOrdinal(culture.InnerText.ToUpperInvariant(), "UNKNOWN")) { Locale = new CultureInfo(culture.InnerText); } } ReadFromDocument(package); }