private void ReadPrgBakXml() { string path = homePath + "prgbak.xml"; if (!File.Exists(path)) { return; } var xml = File.ReadAllText(path); var xr = new XmlCursor(xml); if (!xr.MoveNext()) { throw new XmlException(path + " is not a valid xml file"); } if (!xr.IsElement("prgbak")) { xr.UnexpectedElement(); } if (xr.MoveIn()) { while (xr.MoveNext()) { if (xr.IsElement("backups")) { if (xr.MoveIn()) { while (xr.MoveNext()) { if (xr.IsElement("backup")) { this.backups.Add(new Backup(xr)); } } xr.MoveOut(); } } else { xr.UnexpectedElement(); } } xr.MoveOut(); } // Move into <prgbak> }
internal static Filter FromXml(XmlCursor xr) { if (xr.IsElement("extension")) { return(new Extension(xr)); } else { xr.UnexpectedElement(); return(null); } }
internal static Target FromXml(XmlCursor xr) { if (xr.IsElement("folder")) { return(new Folder(xr)); } else { xr.UnexpectedElement(); return(null); } }
internal Backup(XmlCursor xr) : this() { if (!xr.MoveIn()) { throw new XmlException("<backup> should have sub items"); } while (xr.MoveNext()) { if (xr.IsElement("name")) { this.name = xr.Text; } else if (xr.IsElement("zipname")) { this.zipname = xr.Text; } else if (xr.IsElement("folder")) { this.folder = xr.Text; } else if (xr.IsElement("lastBackup")) { this.lastBackup = long.Parse(xr.Text); } else if (xr.IsElement("filters")) { if (xr.MoveIn()) { while (xr.MoveNext()) { AddFilter(Filter.FromXml(xr)); } xr.MoveOut(); } } else if (xr.IsElement("targets")) { if (xr.MoveIn()) { while (xr.MoveNext()) { AddTarget(Target.FromXml(xr)); } xr.MoveOut(); } } else { xr.UnexpectedElement(); } } xr.MoveOut(); }