public RestoreManager(XElement xml, List <CloudBackupService> cloud_backup_services, KeyManager key_manager, ReportEvent_Callback report_event = null) { // <default_destinations> var default_destinations_tag = xml.Element("default_destinations"); if (default_destinations_tag != null) { foreach (var tag in default_destinations_tag.Elements("default_destination")) { string prefix = tag.Attribute("embedded_prefix").Value; string destination = tag.Attribute("destination").Value; if (default_destinations.ContainsKey(prefix)) { throw new Exception("XML file error. The <RestoreManager> contain " + "an <default_destination> with the embedded_prefix \"" + prefix + "\", which has already been previously defined."); } default_destinations.Add(prefix, destination); } } // All restore objects use the same decrypt_stream. DecryptStream decrypt_stream = new DecryptStream(key_manager); // <restores> var restores_tag = xml.Element("restores"); if (restores_tag != null) { foreach (var tag in restores_tag.Elements("restore")) { restores.Add(new Restore(tag, cloud_backup_services, decrypt_stream, key_manager, report_event)); } } }
public Restore(XElement xml, List <CloudBackupService> cloud_backup_services, DecryptStream decrypt_stream, KeyManager key_manager, ReportEvent_Callback report_event = null) { this.decrypt_stream = decrypt_stream; this.key_manager = key_manager; this.report_event = report_event; // <destination_name> backup_destination_name = xml.Element("destination_name").Value; if (backup_destination_name.Equals("disk") == false) { // search for the destination in cloud_backup_services foreach (var cloud_backup in cloud_backup_services) { if (backup_destination_name.Equals(cloud_backup.Name)) { this.cloud_backup = cloud_backup; break; } } if (cloud_backup == null) { throw new Exception("XML file error. While processing <RestoreManager> " + "there is a <restore> with destination_name \"" + backup_destination_name + "\" that refers to an unknown cloud backup service."); } } // <destination_path>, <file_prefixes> backup_destination_base = xml.Element("destination_path").Value; file_prefixes = xml.Element("file_prefixes").Value.Trim().Split(' '); }