static string GetMultiText(MultiGameRequirementMissingException multiGameRequirementMissingException) { var text = new List<string>(); foreach (var ex in multiGameRequirementMissingException.Exceptions) { if (ex is OpenIvMissingException) text.Add(OpenIv); else if (ex is ScriptHookMissingException) text.Add(ScriptHook); } return string.Join("\n", text); }
static IEnumerable<IRecoveryCommand> GetMultiCommands( MultiGameRequirementMissingException multiGameRequirementMissingException) { foreach (var ex in multiGameRequirementMissingException.Exceptions) { if (ex is OpenIvMissingException) { var webBrowserCommand = new NonRecoveryCommand("Get OpenIV"); webBrowserCommand.Subscribe( x => Cheat.Mediator.RequestAsync(new OpenArbWebLink(new Uri("http://openiv.com")))); yield return webBrowserCommand; } else if (ex is ScriptHookMissingException) { var scriptHookCommand = new NonRecoveryCommand("Get ScriptHookV"); scriptHookCommand.Subscribe( x => Cheat.Mediator.RequestAsync( new OpenArbWebLink(new Uri("http://www.dev-c.com/gtav/scripthookv")))); yield return scriptHookCommand; } } }
static DependencyMissingUserError Handle(MultiGameRequirementMissingException ex, string action) => new DependencyMissingUserError("Please install the following components", GetMultiText(ex), RecoveryCommands.RetryCommands.Concat(GetMultiCommands(ex)), innerException: ex);