public FileMerger( MergeInventory inventory, ProgressChangedEventHandler progressHandler, RunWorkerCompletedEventHandler completedHandler) { _inventory = inventory; _bgWorker = new BackgroundWorker { WorkerReportsProgress = true }; _bgWorker.ProgressChanged += progressHandler; ProgressInfo = new MergeProgressInfo(); ProgressInfo.PropertyChanged += (sender, e) => { _bgWorker.ReportProgress(0, ProgressInfo); }; _bgWorker.RunWorkerCompleted += completedHandler; }
public static MergeInventory Load(string path) { MergeInventory inventory; try { _serializer = new XmlSerializer(typeof(MergeInventory)); using (var stream = File.OpenRead(path)) { inventory = (MergeInventory)_serializer.Deserialize(stream); } AddMissingHashes(inventory); } catch { inventory = new MergeInventory(); } inventory.ScriptsChanged = inventory.XmlChanged = inventory.BundleChanged = false; return inventory; }
public static MergeInventory Load(string path) { MergeInventory inventory; try { _serializer = new XmlSerializer(typeof(MergeInventory)); using (var stream = File.OpenRead(path)) { inventory = (MergeInventory)_serializer.Deserialize(stream); } AddMissingHashes(inventory); } catch { inventory = new MergeInventory(); } inventory.ScriptsChanged = inventory.XmlChanged = inventory.BundleChanged = false; return(inventory); }
// Adds file hashes to old inventories that don't have them static void AddMissingHashes(MergeInventory inventory) { var anyMissing = false; foreach (var merge in inventory.Merges) { foreach (var mod in merge.Mods) { if (mod.Hash == null) { anyMissing = true; mod.Hash = Tools.Hasher.ComputeHash(merge.GetModFile(mod.Name)); } } } if (anyMissing) { inventory.Save(); } }
// Adds file hashes to old inventories that don't have them static void AddMissingHashes(MergeInventory inventory) { var anyMissing = false; foreach (var merge in inventory.Merges) { foreach (var mod in merge.Mods) { if (mod.Hash == null) { anyMissing = true; mod.Hash = Tools.Hasher.ComputeHash(merge.GetModFile(mod.Name)); } } } if (anyMissing) inventory.Save(); }