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; } } }
// TODO /* * DependencyMissingUserError Handle(OpenIvMissingException ex, string action) { * var webBrowserCommand = new NonRecoveryCommand("Get OpenIV"); * webBrowserCommand.MergeTask( * () => this.SendAsync(new OpenArbWebLink(new Uri("http://openiv.com")))).Subscribe(); * return new DependencyMissingUserError("Please install OpenIV", * OpenIv, * RecoveryCommandsImmediate.RetryCommands.Concat(new[] {webBrowserCommand}), * innerException: ex); * } * * DependencyMissingUserError Handle(ScriptHookMissingException ex, string action) { * var webBrowserCommand = new NonRecoveryCommand("Get ScriptHookV"); * webBrowserCommand.MergeTask( * () => this.SendAsync(new OpenArbWebLink(new Uri("http://www.dev-c.com/gtav/scripthookv")))) * .Subscribe(); * return new DependencyMissingUserError("Please install the latest version of ScriptHook", ScriptHook, * RecoveryCommandsImmediate.RetryCommands.Concat(new[] {webBrowserCommand}), innerException: ex); * } * * DependencyMissingUserError Handle(MultiGameRequirementMissingException ex, string action) * => new DependencyMissingUserError("Please install the following components", GetMultiText(ex), * RecoveryCommandsImmediate.RetryCommands.Concat(GetMultiCommands(ex)), innerException: ex); * * IEnumerable<IRecoveryCommand> GetMultiCommands( * MultiGameRequirementMissingException multiGameRequirementMissingException) { * foreach (var ex in multiGameRequirementMissingException.Exceptions) { * if (ex is OpenIvMissingException) { * var webBrowserCommand = new NonRecoveryCommand("Get the latest OpenIV"); * webBrowserCommand * .MergeTask(() => this.SendAsync(new OpenArbWebLink(new Uri("http://openiv.com")))) * .Subscribe(); * yield return webBrowserCommand; * } else if (ex is ScriptHookMissingException) { * var scriptHookCommand = new NonRecoveryCommand("Get the latest ScriptHookV"); * scriptHookCommand * .MergeTask(() => * this.SendAsync( * new OpenArbWebLink(new Uri("http://www.dev-c.com/gtav/scripthookv")))).Subscribe(); * scriptHookCommand * .MergeTask( * () => * this.SendAsync(new OpenArbWebLink(new Uri("http://www.dev-c.com/gtav/scripthookv")))) * .Subscribe(); * yield return scriptHookCommand; * } * } * } */ 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 DependencyMissingUserError Handle(MultiGameRequirementMissingException ex, string action) => new DependencyMissingUserError("Please install the following components", GetMultiText(ex), RecoveryCommands.RetryCommands.Concat(GetMultiCommands(ex)), innerException: ex);