public bool TryRestoreFirstpassBackup() { bool result; try { result = _fileManager.RestoreBackupForFile(Paths.DefaultAssemblyFirstPassPath); } catch (Exception e) { Status = "Can't restore Assembly-CSharp-firstpass.dll backup."; _logger.Log(e); result = false; } RestoreBackupCommand.RaiseCanExecuteChanged(); return(result); }
public void Patch() { Status = $"[{DateTime.Now.TimeOfDay}] Patching started."; _logger.LogProperties(State); if (CanRestoreCSharpBackup()) { if (IsCSharpPatched) { if (TryRestoreCSharpBackup()) { Status = "\tAssembly-CSharp.dll backup restored."; } else { Status = "\tAssembly-CSharp.dll backup failed.\n\tPatch cancelled."; return; } } else { Status = "\tAssembly-CSharp.dll backup restore SKIPPED."; } } if (CanRestoreFirstpassBackup()) { if (IsFirstpassPatched) { if (TryRestoreFirstpassBackup()) { Status = "\tAssembly-CSharp-firstpass.dll backup restored."; } else { Status = "\tAssembly-CSharp-firstpass.dll backup failed.\n\tPatch cancelled."; return; } } else { Status = "\tAssembly-CSharp-firstpass.dll backup restore SKIPPED."; } } try { Status = _injector.InjectDefaultAndBackup(State) ? "\tSome issues with injection appeared, check logs for more info\n\tOriginal backed up and patched.\n\tPatch complete." : "\tOriginal backed up and patched.\n\tPatch successful."; } catch (Exception e) { Status = "\tInjection failed."; _logger.Log(e); return; } RestoreBackupCommand.RaiseCanExecuteChanged(); try { IOHelper.EnsureDirectoryExists(Common.Paths.MaterialConfigPath); } catch (Exception e) { Status = "Can't create or access directory for state to save."; _logger.Log(e); return; } try { _stateManager.SaveState(State); } catch (Exception e) { Status = "Can't save app state."; _logger.Log(e); return; } }