2021-03-27 15:12:05 +01:00
|
|
|
using Ryujinx.HLE.HOS.Tamper.Conditions;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Tamper.Operations
|
|
|
|
{
|
|
|
|
class IfBlock : IOperation
|
|
|
|
{
|
|
|
|
private ICondition _condition;
|
2021-08-04 22:05:17 +02:00
|
|
|
private IEnumerable<IOperation> _operationsThen;
|
|
|
|
private IEnumerable<IOperation> _operationsElse;
|
2021-03-27 15:12:05 +01:00
|
|
|
|
2021-08-04 22:05:17 +02:00
|
|
|
public IfBlock(ICondition condition, IEnumerable<IOperation> operationsThen, IEnumerable<IOperation> operationsElse)
|
2021-03-27 15:12:05 +01:00
|
|
|
{
|
|
|
|
_condition = condition;
|
2021-08-04 22:05:17 +02:00
|
|
|
_operationsThen = operationsThen;
|
|
|
|
_operationsElse = operationsElse;
|
2021-03-27 15:12:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
{
|
2021-08-04 22:05:17 +02:00
|
|
|
IEnumerable<IOperation> operations = _condition.Evaluate() ? _operationsThen : _operationsElse;
|
|
|
|
|
|
|
|
if (operations == null)
|
2021-03-27 15:12:05 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-04 22:05:17 +02:00
|
|
|
foreach (IOperation op in operations)
|
2021-03-27 15:12:05 +01:00
|
|
|
{
|
|
|
|
op.Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|