public static ApplicationItemOptions FromXml(XmlReader reader) { ApplicationItemOptions options = new ApplicationItemOptions(); // If this is an empty option element then don't read further if (reader.IsEmptyElement) return options; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == Resources.DownloadLatestVersion) { options.DownloadLatestVersion = true; } else if (reader.Name == Resources.SilentInstall) { options.SilentInstall = true; } else if (reader.Name == Resources.PostInstallScript) { if (reader.IsEmptyElement == false) { options.PostInstallScript = reader.ReadString().Trim(); reader.ReadEndElement(); } } else if (reader.Name == Resources.InstallationRoot) { if (reader.IsEmptyElement == false) { options.InstallationRoot = reader.ReadString(); reader.ReadEndElement(); } } else if (reader.Name == Resources.AlternateFileUrl) { if (reader.IsEmptyElement == false) { options.AlternateFileUrls.Add(reader.ReadString()); reader.ReadEndElement(); } } else if (reader.Name == Resources.InstallerArguments) { if (reader.IsEmptyElement == false) { options.InstallerArguments = reader.ReadString(); reader.ReadEndElement(); } } else if (reader.Name == Resources.Checked) {//Legacy. Replaced by CheckedByDefault bool value = true; try { value = bool.Parse(reader.ReadString()); } catch (Exception) { } options.CheckedByDefault = value; } else if (reader.Name == Resources.CheckedByDefault) { bool value = true; try { value = bool.Parse(reader.ReadString()); } catch (Exception) { } options.CheckedByDefault = value; } else options.XmlErrors.Add(String.Format("{0}: \"{1}\"", Resources.AppListXmlUnknown, reader.Name)); break; case XmlNodeType.EndElement: // Only stop reading when we've hit the end of the Options element if (reader.Name == Resources.Options) return options; break; } } return options; }
public static ApplicationItem FromXml(XmlReader reader) { ApplicationItem item = new ApplicationItem(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == Resources.Name) { if (reader.IsEmptyElement == false) { item.Name = reader.ReadString(); reader.ReadEndElement(); } } else if (reader.Name == Resources.FileUrl) { if (reader.IsEmptyElement == false) { item.DownloadUrl = reader.ReadString(); reader.ReadEndElement(); } } else if (reader.Name == Resources.Comment) { if (reader.IsEmptyElement == false) { item.Comment = reader.ReadString(); reader.ReadEndElement(); } } // Get the HomePage URL and link Caption. else if (reader.Name == Resources.HomePageUrl) { if (reader.IsEmptyElement == false) { item.HomePageUrl = reader.ReadString(); reader.ReadEndElement(); } } else if (reader.Name == Resources.Options) { item.Options = ApplicationItemOptions.FromXml(reader); item.XmlErrors.AddRange(item.options.XmlErrors); } else { item.XmlErrors.Add( String.Format("{0}: \"{1}\"", Resources.AppListUnknownElement, reader.Name)); } break; case XmlNodeType.EndElement: if (reader.Name == Resources.Application) { item.DetectVersion(); return(item); } break; } } item.DetectVersion(); return(item); }
public static ApplicationItemOptions FromXml(XmlReader reader) { ApplicationItemOptions options = new ApplicationItemOptions(); // If this is an empty option element then don't read further if (reader.IsEmptyElement) { return(options); } while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == Resources.DownloadLatestVersion) { options.DownloadLatestVersion = true; } else if (reader.Name == Resources.SilentInstall) { options.SilentInstall = true; } else if (reader.Name == Resources.PostInstallScript) { if (reader.IsEmptyElement == false) { options.PostInstallScript = reader.ReadString().Trim(); reader.ReadEndElement(); } } else if (reader.Name == Resources.InstallationRoot) { if (reader.IsEmptyElement == false) { options.InstallationRoot = reader.ReadString(); reader.ReadEndElement(); } } else if (reader.Name == Resources.AlternateFileUrl) { if (reader.IsEmptyElement == false) { options.AlternateFileUrls.Add(reader.ReadString()); reader.ReadEndElement(); } } else if (reader.Name == Resources.InstallerArguments) { if (reader.IsEmptyElement == false) { options.InstallerArguments = reader.ReadString(); reader.ReadEndElement(); } } else if (reader.Name == Resources.Checked) { //Legacy. Replaced by CheckedByDefault bool value = true; try { value = bool.Parse(reader.ReadString()); } catch (Exception) { } options.CheckedByDefault = value; } else if (reader.Name == Resources.CheckedByDefault) { bool value = true; try { value = bool.Parse(reader.ReadString()); } catch (Exception) { } options.CheckedByDefault = value; } else { options.XmlErrors.Add(String.Format("{0}: \"{1}\"", Resources.AppListXmlUnknown, reader.Name)); } break; case XmlNodeType.EndElement: // Only stop reading when we've hit the end of the Options element if (reader.Name == Resources.Options) { return(options); } break; } } return(options); }