IfBlock.cs 951 B

12345678910111213141516171819202122232425262728293031323334
  1. using Ryujinx.HLE.HOS.Tamper.Conditions;
  2. using System.Collections.Generic;
  3. namespace Ryujinx.HLE.HOS.Tamper.Operations
  4. {
  5. class IfBlock : IOperation
  6. {
  7. private ICondition _condition;
  8. private IEnumerable<IOperation> _operationsThen;
  9. private IEnumerable<IOperation> _operationsElse;
  10. public IfBlock(ICondition condition, IEnumerable<IOperation> operationsThen, IEnumerable<IOperation> operationsElse)
  11. {
  12. _condition = condition;
  13. _operationsThen = operationsThen;
  14. _operationsElse = operationsElse;
  15. }
  16. public void Execute()
  17. {
  18. IEnumerable<IOperation> operations = _condition.Evaluate() ? _operationsThen : _operationsElse;
  19. if (operations == null)
  20. {
  21. return;
  22. }
  23. foreach (IOperation op in operations)
  24. {
  25. op.Execute();
  26. }
  27. }
  28. }
  29. }